The bit is late, but if you use SSMS, you can put it in SQLCMD mode and define the variables this way. You cannot change variables as soon as you define them, but it is still useful to know.
:setvar MyVariable "FooBar" Select Foo from Bar where FooBar = '$(FooBar)' GO Insert Into Bar(FooBar) Values ('$(FooBar)') GO
source share