Skip to content

Commit 626b117

Browse files
committed
You can check existence of a target linked server before the cloning.
1 parent e01793a commit 626b117

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

try-me-after-install-CloneSP.sql

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,27 @@ GO
1818
EXEC MySampleSP;
1919

2020

21-
-- ! Often must have ANSI_NULLS ON to create a cloned SP.
22-
SET ANSI_NULLS ON;
2321

24-
EXECUTE CloneSP
25-
@source_name = '[dbo].[MySampleSP]',
26-
@target_name = '[dbo].[MyClonedSP]',
22+
-- Checking for existing of a target linked-server.
23+
--IF EXISTS(SELECT * FROM sys.servers WHERE name = N'Replaced_alias__Other_linked_server')
24+
--BEGIN
2725

28-
@sub1_from = 'Server_level_alias__Linked_server',
29-
@sub1_to = 'Replaced_alias__Other_linked_server',
26+
-- ! Often must have ANSI_NULLS ON to create a cloned SP.
27+
SET ANSI_NULLS ON;
3028

31-
@sub2_from = 'MySampleSP',
32-
@sub2_to = 'MyClonedSP'
33-
;
29+
EXECUTE CloneSP
30+
@source_name = '[dbo].[MySampleSP]',
31+
@target_name = '[dbo].[MyClonedSP]',
3432

33+
@sub1_from = 'Server_level_alias__Linked_server',
34+
@sub1_to = 'Replaced_alias__Other_linked_server',
3535

36-
EXEC MyClonedSP;
36+
@sub2_from = 'MySampleSP',
37+
@sub2_to = 'MyClonedSP'
38+
;
39+
40+
41+
EXEC MyClonedSP;
42+
43+
--END;
3744

0 commit comments

Comments
 (0)