Monday, June 4, 2012

Script to Identify and Update the Deleted Records


Script to check if the record exist in Target is deleted in source, then the record in Target will be updated as 1 or True in "IsDeleted" column

SET NOCOUNT ON;
UPDATE [schema_name].[table_name]
SET [IsDeleted] = 1  or True
FROM [schema_name].[table_name] AS T
LEFT OUTER JOIN [schema_name].[table_name2] AS S ON S.column_name = T.column_name
where S.column_name is NULL

select ? = @@ROWCOUNT

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.