File tree Expand file tree Collapse file tree 3 files changed +62
-20
lines changed Expand file tree Collapse file tree 3 files changed +62
-20
lines changed Original file line number Diff line number Diff line change @@ -244,14 +244,28 @@ function New-DbaLogShippingPrimaryDatabase {
244
244
}
245
245
246
246
# ensure unexpected non-success results are caught and thrown as errors:
247
- $Query += "
248
- IF (@SP_Add_RetCode <> 0)
249
- BEGIN
250
- DECLARE @msg VARCHAR(1000);
251
- SELECT @msg = 'Unexpected result executing sp_add_log_shipping_primary_database ('
252
- + CAST (@SP_Add_RetCode AS VARCHAR(5)) + ').';
253
- THROW 51000, @msg, 1;
254
- END"
247
+ if ($server.Version.Major -ge 11 ) {
248
+ $Query += "
249
+ IF (@SP_Add_RetCode <> 0)
250
+ BEGIN
251
+ DECLARE @msg VARCHAR(1000);
252
+ SELECT @msg = 'Unexpected result executing sp_add_log_shipping_primary_database ('
253
+ + CAST (@SP_Add_RetCode AS VARCHAR(5)) + ').';
254
+ THROW 51000, @msg, 1;
255
+ END
256
+ "
257
+ } else {
258
+ $Query += "
259
+ IF (@SP_Add_RetCode <> 0)
260
+ BEGIN
261
+ DECLARE @msg VARCHAR(1000);
262
+ SELECT @msg = 'Unexpected result executing sp_add_log_shipping_primary_database ('
263
+ + CAST (@SP_Add_RetCode AS VARCHAR(5)) + ').';
264
+ RAISERROR (@msg, 16, 1) WITH NOWAIT;
265
+ RETURN;
266
+ END
267
+ "
268
+ }
255
269
256
270
# Execute the query to add the log shipping primary
257
271
if ($PSCmdlet.ShouldProcess ($SqlServer , (" Configuring logshipping for primary database $Database on $SqlInstance " ))) {
Original file line number Diff line number Diff line change @@ -237,14 +237,28 @@ function New-DbaLogShippingSecondaryDatabase {
237
237
$Query += " ;"
238
238
}
239
239
240
- $Query += "
240
+ if ($ServerSecondary.Version.Major -ge 11 ) {
241
+ $Query += "
242
+ IF (@SP_Add_RetCode <> 0)
243
+ BEGIN
244
+ DECLARE @msg VARCHAR(1000);
245
+ SELECT @msg = 'Unexpected result executing sp_add_log_shipping_secondary_database ('
246
+ + CAST (@SP_Add_RetCode AS VARCHAR(5)) + ').';
247
+ THROW 51000, @msg, 1;
248
+ END
249
+ "
250
+ } else {
251
+ $Query += "
241
252
IF (@SP_Add_RetCode <> 0)
242
253
BEGIN
243
254
DECLARE @msg VARCHAR(1000);
244
- SELECT @msg = 'Unexpected result executing sp_add_log_shipping_seondary_database ('
255
+ SELECT @msg = 'Unexpected result executing sp_add_log_shipping_secondary_database ('
245
256
+ CAST (@SP_Add_RetCode AS VARCHAR(5)) + ').';
246
- THROW 51000, @msg, 1;
247
- END"
257
+ RAISERROR (@msg, 16, 1) WITH NOWAIT;
258
+ RETURN;
259
+ END
260
+ "
261
+ }
248
262
249
263
# Execute the query to add the log shipping primary
250
264
if ($PSCmdlet.ShouldProcess ($SqlServer , (" Configuring logshipping for secondary database $SecondaryDatabase on $SqlInstance " ))) {
Original file line number Diff line number Diff line change @@ -205,14 +205,28 @@ function New-DbaLogShippingSecondaryPrimary {
205
205
}
206
206
207
207
# catch any non-success non error and throw:
208
- $Query += "
209
- IF (@SP_Add_RetCode <> 0)
210
- BEGIN
211
- DECLARE @msg VARCHAR(1000);
212
- SELECT @msg = 'Unexpected result executing sp_add_log_shipping_secondary_primary ('
213
- + CAST(@SP_Add_RetCode AS VARCHAR(5)) + ').';
214
- THROW 51000, @msg, 1;
215
- END"
208
+ if ($ServerSecondary.Version.Major -ge 11 ) {
209
+ $Query += "
210
+ IF (@SP_Add_RetCode <> 0)
211
+ BEGIN
212
+ DECLARE @msg VARCHAR(1000);
213
+ SELECT @msg = 'Unexpected result executing sp_add_log_shipping_secondary_primary ('
214
+ + CAST(@SP_Add_RetCode AS VARCHAR(5)) + ').';
215
+ THROW 51000, @msg, 1;
216
+ END
217
+ "
218
+ } else {
219
+ $Query += "
220
+ IF (@SP_Add_RetCode <> 0)
221
+ BEGIN
222
+ DECLARE @msg VARCHAR(1000);
223
+ SELECT @msg = 'Unexpected result executing sp_add_log_shipping_secondary_primary ('
224
+ + CAST (@SP_Add_RetCode AS VARCHAR(5)) + ').';
225
+ RAISERROR (@msg, 16, 1) WITH NOWAIT;
226
+ RETURN;
227
+ END
228
+ "
229
+ }
216
230
# Execute the query to add the log shipping primary
217
231
if ($PSCmdlet.ShouldProcess ($SqlServer , (" Configuring logshipping making settings for the primary database to secondary database on $SqlInstance " ))) {
218
232
try {
You can’t perform that action at this time.
0 commit comments