dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Preventing SQL from Running on a Testing SQL Server

See the two ways to prevent your SQL code from running on a testing or production server.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


There are two ways to prevent your SQL code from running on a testing server or production server. You can use the @@SERVERNAME Variable or the DB_NAME function, as shown next below:

@@SERVERNAME
IF @@SERVERNAME = 'ProductionServerName'
BEGIN
PRINT 'Code will NOT execute'
RETURN
END
ELSE
BEGIN
PRINT 'Code will execute'
END
DB_NAME()
IF DB_NAME() = 'ProductionServerName'
BEGIN
PRINT 'Code will NOT execute'
RETURN
END
ELSE
BEGIN
PRINT 'Code will execute'
END

 

Visit the DevX Tip Bank

 





   
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date