批量生成insert into语句(带有数据)
declare @str varchar(8000)
declare @i int
set @i=1
while(@i<124)
begin
SELECT @str='INSERT INTO Menu(MenuName,MenuIds,ParentId,LinkUrl,Value) VALUES
('+MenuName+',''' + MenuIds+ ''',''' + cast(ParentId as varchar(50))+ ''',''' +LinkUrl+ ''',''' + Value+ ''')' FROM Menu where MenuId=@i
set @i=@i+1
print @str
end
里面的表 字段 自己可以替换。
declare @i int
set @i=1
while(@i<124)
begin
SELECT @str='INSERT INTO Menu(MenuName,MenuIds,ParentId,LinkUrl,Value) VALUES
('+MenuName+',''' + MenuIds+ ''',''' + cast(ParentId as varchar(50))+ ''',''' +LinkUrl+ ''',''' + Value+ ''')' FROM Menu where MenuId=@i
set @i=@i+1
print @str
end