我的表是:
净水头 10 11 12 1 3 14 15 16 ......... 80
20 25.6 24.8 26.3 24.1 25.1 26.5 14.5 ......... 89.4
. . . . . . . . ........... .
. . . . . . . . .
26 25.7 123 245 45 65 78 98 ........... 69
如何能通过输入两个查询条件如:第一个是净水头(TEXT1)第二个是任意列如:10,11,12,13....80中的任意一列(TEXT2)并把查询的值赋给(TEXT3)。谢谢高手们,急...等待中。
净水头 10 11 12 1 3 14 15 16 ......... 80
20 25.6 24.8 26.3 24.1 25.1 26.5 14.5 ......... 89.4
. . . . . . . . ........... .
. . . . . . . . .
26 25.7 123 245 45 65 78 98 ........... 69
如何能通过输入两个查询条件如:第一个是净水头(TEXT1)第二个是任意列如:10,11,12,13....80中的任意一列(TEXT2)并把查询的值赋给(TEXT3)。谢谢高手们,急...等待中。
insert T select 20, 25.6, 24.8, 26.3
union all select 26, 25.7, 123.2, 245.6declare @text1 varchar(255), @text2 varchar(255), @text3 decimal(10,2)
select @text1='26', @text2='10'
declare @sql nvarchar(4000)
set @sql='select @text3=['+@text2+'] from T where 净水头='''+@text1+''''
exec sp_executesql @sql, N'@text3 decimal(10,2) output', @text3 output
select @text3--result
------------
25.70(1 row(s) affected)