2024-10-14 07:10:51
declare @str varchar(500)
declare @insert varchar(8000)
select @insert = 'insert into youTable values '
select @str='str1,1,1,1,1|str2,2,2,2,2|str3,3,3,3,5|str4,4,4,45,4'
select @str=@insert+'('''+@str+''')'
select @str = REPLACE(@str,',',''',''')
select @str = REPLACE(@str,'|',''') '+CHAR(13)+@insert+'(''')
print @str
--exec(@str) 动态执行下生成的语句就好了
--print 结果如下:
insert into youTable values ('str1','1','1','1','1')
insert into youTable values ('str2','2','2','2','2')
insert into youTable values ('str3','3','3','3','5')
insert into youTable values ('str4','4','4','45','4')
2024-10-14 07:10:50