
So first create a temp table above the code: CREATE TABLE #temp ( nvarchar(max), One way to achieve this based on a script that you have is to INSERT the values into a #TEMP table and then INSERT into the main table using a NOT EXISTS clause. This answer is based on the fact you have a pre-generated script you want to work with. VALUES (source., source., source., source. (N'Article', N'exceViewRptArticle art', N'art.ArticleId', N'ATL'))ĪS source (,, , ) (N'Freezed Contracts', N'exceViewRptFreeze fc', N'fc.FreezeItemId', N'FRZ'), USING (VALUES (N'Resource Booking', N'exceViewRptResourceBooking rb', N'rb.BookingId', N'BOK'), VALUES ( N'Resource Booking', N'Test rb', N'Test', N'Test') The source table is a derived table that uses the Transact-SQL table value constructor to specify multiple When the value of does not match, the source row is inserted into the target table. When the value of in the source table matches a value in the Ĭolumn of the target table, (Entity), all the columns are updated in the target table. You can use MERGE to modify the Entity table by updating and inserting rows. Is there any way of doing this using SSMS or any other tool VALUES (N'Article', N'exceViewRptArticle art', N'art.ArticleId', N'ATL') If not exists (select * from USRPT.Entity where DisplayName = 'Article') VALUES (N'Freezed Contracts', N'exceViewRptFreeze fc', N'fc.FreezeItemId', N'FRZ') If not exists (select * from USRPT.Entity where DisplayName = 'Freezed Contracts')

VALUES (N'Resource Booking', N'exceViewRptResourceBooking rb', N'rb.BookingId', N'BOK')

If not exists (select * from USRPT.Entity where DisplayName = 'Resource Booking') VALUES ( N'Article', N'exceViewRptArticle art', N'art.ArticleId', N'ATL')īut i want to do it as follows using scripting tool(because actual data set is large) GO VALUES ( N'Freezed Contracts', N'exceViewRptFreeze fc', N'fc.FreezeItemId', N'FRZ') VALUES ( N'Resource Booking', N'exceViewRptResourceBooking rb', N'rb.BookingId', N'BOK') I created a script for inserting to a table as follows using Task -> generate Script GO
