insert into Gms_礼品 values('LP1111','LPaaaaa','1','880','14.2000','1','1')
执行这条sql语句 
但是改变的880这个字段的值是{1004 1005 1009 1010 1012 1013 1016 1018 1019 
1021 1023 1025 1027 1029 1032 1033 1034 1035
1036 1037 1039 1043 1044 1046 1047 1048  1049
1050 1052 1053 1054 1055 1056 1057 1058 1059 
1064 1066 1067 1068 1069 1070
} 这些值没任何规律 
 有没有可能写个sql语句让他一次 执行完 
谢谢 各位大大了!

解决方案 »

  1.   

    if object_id('f_split')is not null drop function  f_split
    go
    create function f_split
    (
    @s     varchar(8000),  --待分拆的字符串
    @split varchar(10)     --数据分隔符
    )returns table
    as
     return
     (
      select substring(@s,number,charindex(@split,@s+@split,number)-number)as col
      from master..spt_values
      where type='p' and number<=len(@s+'a') 
      and charindex(@split,@split+@s,number)=number
      )
    go
    declare @s varchar(1000)
    set @s='1004 1005 1009 1010 1012 1013 1016 1018 1019 
    1021 1023 1025 1027 1029 1032 1033 1034 1035 
    1036 1037 1039 1043 1044 1046 1047 1048  1049 
    1050 1052 1053 1054 1055 1056 1057 1058 1059 
    1064 1066 1067 1068 1069 1070'
    insert into Gms_礼品 
    select 'LP1111','LPaaaaa','1',col,'14.2000','1','1' from dbo.f_split(@s,' ')
      

  2.   

    Happy_Stone怎么插入数据库了 会有一行 880这个字段的值为空?
      

  3.   

    这个在程序中一个SPLIT方法,然后来个TOSTRING()搞定了
      

  4.   

    set @s='1004 1005 1009 1010 1012 1013 1016 1018 1019 1021 1023 1025 1027 1029 1032 1033 1034 1035 1036 1037 1039 1043 1044 1046 1047 1048  1049 1050 1052 1053 10541055 1056 1057 1058 1059 1064 1066 1067 1068 1069 1070'有的分割符不止一個空格
    所以~~