PDA

View Full Version : SQL Text Replacement Question



rguggisberg
06-26-2017, 04:08 PM
Suppose I have literal brackets ([&]) in my SQL script. How do I do text replacement?
For example... suppose I have the line
BACKUP DATABASE [MyDatabaseName]
How would I do text replacement using the property YOUR_DATABASE_NAME?

Thanks.

chad.petersen
06-27-2017, 10:10 AM
I always make the SQL Script so it has a chance of running outside of the installer still.

So I would take a default database name and use that in the script like

BACKUP DATABASE DCP_PROD

Then in the text replacement just do

DCP_PROD -> [YOUR_DATABASE_NAME]

Actually, I use

DCP_PROD -> [IS_SQLSERVER_DATABASE]

More often so I can capture the name of the catalog/database they typed into the UISequence and substitute that in the text replacement.

Chad

rguggisberg
06-27-2017, 11:11 AM
Thanks Chad. Another way to resolve is to just remove the [] as long as spaces are not allowed in the database name.