Sql Server, How To Remove Updates Elements From User-defined Table Type?
I have a User-Defined Table Type, lets say @TT dbo.IntType readonly, IntType is batch of int, as Primary-Key CREATE TYPE [dbo].[IntType] AS TABLE( [T] [int] NOT NULL, PRIMA
Solution 1:
Use the MERGE
statement.
http://technet.microsoft.com/en-us/library/bb510625.aspx
Let me see if I can put something together.
EDIT: Example
MERGEINTO [TargetTable] AS T
USING (SELECT l.T AS'id'FROM@list l ) AS S
ON (T.[id] = S.[id])
WHEN MATCHED THENUPDATESET
T.updated =1WHENNOT MATCHED THENINSERTVALUES ([insertvalueintoeachcolumnof target table]);
EDIT 2: The parameter @list
is the list that is passed in that you populated with the ids
Post a Comment for "Sql Server, How To Remove Updates Elements From User-defined Table Type?"