Variable substitution in Data Dude Scripts - SimonS Blog on SQL Server Stuff

Variable substitution in Data Dude Scripts

One of the great aspects of Data Dude is that it uses SQLCmd to run the scripts. This means that it can use the variable substitution. One gotcha however is that Data Dude tries to be clever and validate your code before the substiution. This means something like.

if exists (select 1 from $(databasename).sys.objects where name = 'blah') doesn't validate because $ is not valid for a object name.

There is an easy workaround. Put [] around your object so the example above becomes

if exists (select 1 from [$(databasename)].sys.objects where name = 'blah')



-
Published 30 November 2006 18:02 by simonsabin

Comments

No Comments