Saturday, 24 February 2018

How to create Insert or Update query from select statement

Description : In this post how to create a insert or update query using select query in sql server

- Insert Query
SELECT 'INSERT INTO AspNetRoles VALUES ('''+CONVERT(NVARCHAR(50),Id)+''', '''+Name+''')' FROM AspNetRoles

- Update Query
SELECT 'UPDATE AspNetRoles SET Name = '+Name+' WHERE ID = '+Id+'' FROM AspNetRoles

No comments:

Post a Comment