o*****s 发帖数: 193 | 1 We have the following statement, which SQL Server does not
accept due to grammar problem:
declare @product varchar(32)
select @product = "product"
select * from @product
Is there any way we can select the record from a table whose
name is provided using a variable?
Thanks a lot. | s*****c 发帖数: 36 | 2 you can use ODBC to solve this problem. | r****r 发帖数: 2 | 3 declare @sqlcmd varchar(1024),
@product varchar(32)
select @procut = 'product'
select @sqlcmd = 'select * from ' +
quoatename(@product,'''')
exec(@sqlcmd)
that's it.
【在 o*****s 的大作中提到】 : We have the following statement, which SQL Server does not : accept due to grammar problem: : declare @product varchar(32) : select @product = "product" : select * from @product : Is there any way we can select the record from a table whose : name is provided using a variable? : Thanks a lot.
|
|