请问我要在一张表中随机插入1000条数据,这张表里有name(varchar 50) passwd(int) CreateTime(datatime),其中NAME是主键,而且数据要求是中文,所有字段都要有数据,要怎样做,謝謝

解决方案 »

  1.   

    用随机函数.
    汉字可以用随机函数生成一个unicode码再转换成汉字,时间也可以随机生成的.
      

  2.   

    --如果存在另外一个相同结构的表tb2,其内容符合你的需求。insert into tb1 select top 1000 * from tb2 order by newid()--如果不存在,就自己先构造一个。
      

  3.   

    use testdbcreate table a(id int)declare @i int
    declare @n int
    set @i = 1
    set @n = 176
    while (@i <= 71)
    begin insert a values(@n)
     set @i = @i + 1 
     set @n = @n+1
    end select * from acreate table b(id int)declare @i int
    declare @n int
    set @i = 1
    set @n = 161
    while (@i <= 94)
    begin insert b values(@n)
     set @i = @i + 1 
     set @n = @n+1
    end select * from bselect count(*)
    from (select a.id as aid,cast(a.id as binary(1)) as abinary,b.id as bid,cast(b.id as binary(1)) as bbinary,
    a.id+b.id as absum,
    cast((cast(a.id as binary(1))+cast(b.id as binary(1))) as binary(2)) as prcch,cast((cast(a.id as binary(1))+cast(b.id as binary(1))) as char(2)) as ch
    from a,bwhere
    not(
    a.id = 215 and b.id between 250 and 254
    )) as t
    create table ab
    (
    aid int,
    abinary binary(1),
    bid int,
    bbinary binary(1),
    absum int,
    prcch binary(2),
    ch char(2)
    )select * from ab
    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/dillonhunter/archive/2006/05/07/711646.aspx