日期:2014-05-17 浏览次数:20548 次
CREATE TABLE TB(CraneType VARCHAR(10), TableName VARCHAR(255))
INSERT TB SELECT '003','CraneOperation3'
DECLARE @sql NVARCHAR(MAX),@CraneType VARCHAR(10)
SET @CraneType = '003'
SET @sql =
(
SELECT N'SELECT * FROM '+QUOTENAME(TableName)
FROM TB
where CraneType = @CraneType
)
--PRINT @sql
EXEC(@sql)