0

在这里我想用表格的列显示变量值

declare @BaseMetal varchar(40)
set @BaseMetal='18K'

 SELECT   CAST(@BaseMetal as varchar(40)) 'BaseMetal', tbl.Columm1,tbl.Columm2, tbl.Columm3 from tbl

O/P 应该是:

BaseMetal   Columm1   Columm2     Columm3 
  18K       colval1    colval1    colval1
  18K       colval2    colval2    colval2

但是当我尝试它显示错误Must declare the scalar variable "@BaseMetal".

4

1 回答 1

0

你不需要演员表。

declare @BaseMetal varchar(40)
set @BaseMetal='18K'

SELECT   @BaseMetal AS 'BaseMetal', tbl.Columm1,tbl.Columm2, tbl.Columm3 from tbl
于 2013-08-13T09:19:24.360 回答