这里我想要显示带表格列的变量值
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".
答案 0 :(得分:0)
你不需要演员。
declare @BaseMetal varchar(40)
set @BaseMetal='18K'
SELECT @BaseMetal AS 'BaseMetal', tbl.Columm1,tbl.Columm2, tbl.Columm3 from tbl