由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Question about T-SQL
相关主题
SQL Server - delcare variable dynamicallyget value returned by SQLstored procedure from python (转载)
SQL Server 2008 Exp 怎么export DBF file?SQL Server - how to obtain data type name
SQL请教...怎么写这样的distribution list请教set和select 的区别
请教一个有关SQL concat的问题A question about recursive query
T-SQL 问题请各位帮我看看这个最简单的Stored Procedure (转载)
求助:如何ColumName 作为变量放入queryquestion about import xml to sql table
问一个SQL Server的问题请问sql server里面怎么输出变量到文本文件?
error of executing SQL query of string concatenation (转载pass parameter from stored procedure to SSIS
相关话题的讨论汇总
话题: product话题: select话题: sql话题: question话题: varchar
进入Database版参与讨论
1 (共1页)
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.

1 (共1页)
进入Database版参与讨论
相关主题
pass parameter from stored procedure to SSIST-SQL 问题
SQL Server 如何把日期自动加入文件名中?求助:如何ColumName 作为变量放入query
问一个sql查询语句的问题问一个SQL Server的问题
SQL2005 如何獲取所有 user login database mappingerror of executing SQL query of string concatenation (转载
SQL Server - delcare variable dynamicallyget value returned by SQLstored procedure from python (转载)
SQL Server 2008 Exp 怎么export DBF file?SQL Server - how to obtain data type name
SQL请教...怎么写这样的distribution list请教set和select 的区别
请教一个有关SQL concat的问题A question about recursive query
相关话题的讨论汇总
话题: product话题: select话题: sql话题: question话题: varchar