Home All Groups Group Topic Archive Search About

Help with Syntax please

Author
3 Nov 2005 5:01 PM
Lesley
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

Author
3 Nov 2005 5:07 PM
Aaron Bertrand [SQL Server MVP]
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

AddThis Social Bookmark Button