Home All Groups Group Topic Archive Search About

SQL dynamique table name and column name as variable - Problem

Author
16 Mar 2007 10:31 AM
ina
Hello guys,

I have a question. Is it possible to pass the table name and column
name as variables like this :

DECLARE @table sysname
DECLARE @tableID int
DECLARE @COLNAME  varchar (200)

SET @tableID = 196532963
SET @table = dbo.UDF_TABLE_NAME (@tableID)

SELECT @COLNAME  = dbo.udf_select_colname(tag) FROM @table

select @colname

I had problem with the table name
Server: Msg 137, Level 15, State 2, Line 9
Must declare the variable '@table'.

Any Suggestions?

Ina

AddThis Social Bookmark Button