Monday, March 19, 2012

from clause

How to write Select..From with declared variable?
I want to do something like this..
declare @.table varchar(50)
set @.table = 'Users'
Select name
From @.table
HrckoAre you talking about a table variable? Look it up in the Books
OnLine; basic syntax is
DECLARE @.table TABLE (name varchar(100))
INSERT INTO @.table (name)
VALUES('Tom')
SELECT name FROM @.table
HTH,
Stu|||Hi
Dynamic SQL:
http://www.sommarskog.se/dynamic_sql.html
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Hrcko" <hrvoje.voda2@.zg.htnet.hr> wrote in message
news:dn2bcb$4j9$1@.ss405.t-com.hr...
> How to write Select..From with declared variable?
> I want to do something like this..
> declare @.table varchar(50)
> set @.table = 'Users'
> Select name
> From @.table
> Hrcko
>

No comments:

Post a Comment