Use Select To Generate Any Insert/Delete/Update Statement

时间:2023-03-08 22:42:13
Use Select To Generate Any Insert/Delete/Update Statement

If you don't have the permission to generate script according to an existing db, but you have the read permission for that db, if so you can use select to generate the expceted insert/delete/update statements, furtherly, you can also do complicated condition jugement when generate the string.

Below is just persudo code:

select 'insert into tabe1 (file1,fiel2) values (''' + userid +'''' + ',' case userid when null
begin
'Null'
end
else
begin
userid
end
end case
from SurfacedCosmosdata