Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dnaes
Starting Member
3 Posts |
Posted - 2007-12-16 : 12:08:28
|
| declare @rej_nm as varchar(50)exec ('select count(*), ' + "'@rej_nm'" + 'from ' + @rej_nm)trying to return the rowcount AND the name of the object. return set should look like this:12, tbl_namei've tried single quotes around @rej_nm, nested single quotes, single/double nested, etc..instead, i get an error stating that @rej_nm is not a valid column of tbl_name. bottomline...how do i return a variable 'value' within a select statement...thanks! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-16 : 12:19:19
|
| try this:-exec ('select count(*),''' + @rej_nm + ''' from ' + @rej_nm) |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-12-16 : 16:55:18
|
select o.name,i.rowsfrom sysobjects ojoin sysindexes i on o.id = i.idwhere o.xtype = 'U' and i.indid < 2order by i.rows desc elsasoft.org |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-17 : 03:16:14
|
| provided you run DBCC updateusage('dbname','tablename') with row_countsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|