|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help with Syntax pleaseI want to insert @DBNAME before the tables in the from section.
Would someone help me with the syntax? Thanks! set @DBNAME = N'AFD.dbo.' SELECT @NumRows = count(*) from @DBNAME + tbl_Revenue Rev, @DBNAME + tbl_RevenueTransactions RevTrans WHERE Rev.RevenueID = RevTrans.RevenueID AND Rev.ClassCode = @ClassCode AND Rev.FsPeriodAppliedY = @FiscalYear
http://www.sommarskog.se/dynamic_sql.html
Show quote "Lesley" <Les***@discussions.microsoft.com> wrote in message
news:A1932385-9D02-44ED-A71E-EB87AAD7C546@microsoft.com... >I want to insert @DBNAME before the tables in the from section. > Would someone help me with the syntax? > Thanks! > > set @DBNAME = N'AFD.dbo.' > > SELECT @NumRows = count(*) from > @DBNAME + tbl_Revenue Rev, @DBNAME + tbl_RevenueTransactions RevTrans > WHERE Rev.RevenueID = RevTrans.RevenueID AND > Rev.ClassCode = @ClassCode AND > Rev.FsPeriodAppliedY = @FiscalYear |
|||||||||||||||||||||||