I want to accomplish this:
update @sourceDatabase.dbo.PredictedPrices
and then set @sourceDatabase
as a variable.
But I'm not allowed?
Incorrect syntax near '.'.
Is there another way?
DECLARE @Dynsql NVARCHAR(MAX)
DECLARE @sourceDatabase sysname
DECLARE @MinPrice MONEY
SET @sourceDatabase = 'foo'
SET @MinPrice = 1.00
SET @Dynsql = N'update ' + QUOTENAME(@sourceDatabase) + '.dbo.PredictedPrices
set MinPrice = @MinPrice'
EXECUTE sp_executesql @Dynsql,
N'@MinPrice money',
@MinPrice = @MinPrice;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With