我在SQL Server 2012中有一個存儲過程,由控制檯應用程序(使用MS Visual Studio 2013的VB)通過傳遞2個參數來執行。對所存儲的過程的代碼是在這裏:如何命名CASE語句
ALTER procedure [dbo].[OptimiserReads_getMaxValue]
@ReadDate datetime,
@tagname nvarchar(50)
AS
Begin
declare @first float
declare @second float
set @first = '265'
set @second = (select value
from RawHistorianData
where interval = @readdate and tagname = @tagname)
Select
CASE when @first > @second then @first else @second end
end
基本上它應導致在任一@first
或@second
結果的結果。如果我在SQL Server Management Studio中執行這個過程,我會得到所需的結果。
在控制檯應用程序中,我不知道如何命名結果由於CASE
聲明。如何給結果的名稱在SQL即像
Select CASE (when @first > @second then @first else @second) as value
Arrrggghhhhh !!!我把它放在最後。謝謝 – Silentbob