brand表结构如下 
字段名          字段类型              默认值 
ID               Guid                newid() 
BrandName  
createTime       DateTime            getdate() sql语句如下:把某个表的数据插入到brand表中。 
insert into brand(BrandName) 
select made.madename from made 
inner join country on made.madecountry = country.countryname order by made.madefirstletter 插入成功后,问题来了,所有数据的createTime的值都是一样。 
请问:如何让插入的每条数据中字段createTime 的值都不一样?

解决方案 »

  1.   

    declare cur cursor for
    select made.madename from made
    inner join country on made.madecountry = country.countryname order by made.madefirstletter 
    declare @BrandName nvarchar(100)
    open cur 
    fetch next from  into @BrandName
    while @@fetch_status=0
    begin
    insert into brand(BrandName) values(@BrandName)
    fetch next from  into @BrandName
    end
    close cur
    deallocate cur改為
      

  2.   


    create proc mypro
    as
    declare @brandname1 uniqueidentifier
    declare @brandname2 nvarchar(50)
    declare @brandname3 varchar(100)
    declare @brandname4 nvarchar(4000)
    declare cur cursor for 
    select country.countryid,made.madename,made.madelogo,made.madehistory from made
    inner join country on made.madecountry = country.countryname order by made.madefirstletter
    open cur
    fetch next from cur
     into @brandname1,@brandname2,@brandname3,@brandname4
    WHILE @@FETCH_STATUS=0
    begin 
        insert into brand(CountryID,BrandName,Logo,BriefIntroduction) values(@brandname1,@brandname2,@brandname3,@brandname4)
        fetch next from cur into @brandname1,@brandname2,@brandname3,@brandname4
    end
    close cur
    deallocate curexec  mypro
    用了游标来处理,但是还有某些数据的createDate的值相同。
    该如何弄成不相同呢?