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')


This is cross posted from my SQLBlogcasts blog which can be found here, http://sqlblogcasts.com/blogs/simons/Variable substitution in Data Dude Scripts

Categories:

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Theme design by Nukeation based on Jelle Druyts