forked from brianary/scripts
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
if exists (select * from information_schema.columns where table_schema = 'Person' and table_name = 'PhoneNumberType' | ||
and columnproperty(object_id(table_name), column_name,'IsIdentity') = 1) | ||
set identity_insert [Person].[PhoneNumberType] on; | ||
|
||
merge [Person].[PhoneNumberType] as target | ||
using ( values | ||
(1, 'Cell', '2017-12-13 13:19:22.27300'), | ||
(2, 'Home', '2017-12-13 13:19:22.27300'), | ||
(3, 'Work', '2017-12-13 13:19:22.27300') | ||
) as source ([PhoneNumberTypeID], [Name], [ModifiedDate]) | ||
on source.[PhoneNumberTypeID] = target.[PhoneNumberTypeID] | ||
when matched then | ||
update set [Name] = source.[Name], | ||
[ModifiedDate] = source.[ModifiedDate] | ||
when not matched by target then | ||
insert ([PhoneNumberTypeID], [Name], [ModifiedDate]) | ||
values (source.[PhoneNumberTypeID], source.[Name], source.[ModifiedDate]) | ||
when not matched by source then delete ; | ||
|
||
if exists (select * from information_schema.columns where table_schema = 'Person' and table_name = 'PhoneNumberType' | ||
and columnproperty(object_id(table_name), column_name,'IsIdentity') = 1) | ||
set identity_insert [Person].[PhoneNumberType] off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
if exists (select * from information_schema.columns where table_schema = 'Production' and table_name = 'ProductModelIllustration' | ||
and columnproperty(object_id(table_name), column_name,'IsIdentity') = 1) | ||
set identity_insert [Production].[ProductModelIllustration] on; | ||
|
||
merge [Production].[ProductModelIllustration] as target | ||
using ( values | ||
(7, 3, '2014-01-09 14:41:02.16700'), | ||
(10, 3, '2014-01-09 14:41:02.16700'), | ||
(47, 4, '2014-01-09 14:41:02.18300'), | ||
(47, 5, '2014-01-09 14:41:02.18300'), | ||
(48, 4, '2014-01-09 14:41:02.18300'), | ||
(48, 5, '2014-01-09 14:41:02.18300'), | ||
(67, 6, '2014-01-09 14:41:02.20000') | ||
) as source ([ProductModelID], [IllustrationID], [ModifiedDate]) | ||
on source.[ProductModelID] = target.[ProductModelID] | ||
and source.[IllustrationID] = target.[IllustrationID] | ||
when matched then | ||
update set [ModifiedDate] = source.[ModifiedDate] | ||
when not matched by target then | ||
insert ([ProductModelID], [IllustrationID], [ModifiedDate]) | ||
values (source.[ProductModelID], source.[IllustrationID], source.[ModifiedDate]) | ||
when not matched by source then delete ; | ||
|
||
if exists (select * from information_schema.columns where table_schema = 'Production' and table_name = 'ProductModelIllustration' | ||
and columnproperty(object_id(table_name), column_name,'IsIdentity') = 1) | ||
set identity_insert [Production].[ProductModelIllustration] off; |