RE: Inserting record count into a variable using variable table n ame

RE: Inserting record count into a variable using variable table n ame

 

  

Simon,

Thanks.

I am still getting the following message:

Must declare the variable '@table_name'.

Here are the exact codes:

declare @table_name varchar(20),
@count INT

set @table_name='ORD_TABLES'
set @count = (select count(*) from @table_name)

Sang Nahm

-----Original Message-----
From: Simon Holdsworth [mailto:Simon.[Email Address Removed] Tuesday, September 17, 2002 10:32 AM
To: 'sang.[Email Address Removed] LazyDBA.com Discussion
Subject: RE: Inserting record count into a variable using variable table
n ame


set @record_count = (select count(*) from @tableName)


-----Original Message-----
From: sang.[Email Address Removed] [mailto:sang.[Email Address Removed]
Sent: Tuesday, September 17, 2002 8:29 AM
To: LazyDBA.com Discussion
Subject: Inserting record count into a variable using variable table
name

Hi,

I have the following declared:

DECLARE @tableName varchar(20),
@record_count INT

set @tableName='EMPLOYEES'

I would like to something like this:

select @record_count = count(*) from @tableName

But I get the following error:
Incorrect syntax near '@table_name'.

I think it is something easy, but I rather seek your assitance instead of
spending much time figuring out (LazyDBA).

Thank you much.

Sang Nahm

---------------------------------------------------------------------
To unsubscribe, e-mail: mssqldba-[Email Address Removed] additional commands, e-mail: mssqldba-[Email Address Removed]MS Sql Server LazyDBA home page