これは以前に尋ねられたことがわかりましたが、その答えはスクリプト固有のものだと思います。これは私が初めてprocを作成し、テーブル変数を使うことです。私はテーブルをアンピボットし、そこからユーザコントロール用のGridViewを生成しています。次に、ユーザーコントロールのチェックボックスをオンにして、元のテーブルを更新するためにそのピボットをピボットする必要があります。 私が必要とする最後の部分は、このprocを作成することです。条件が「select」の近くにあると予想されるコンテキストで指定された非ブール型の式
これはいくつかの方法がありますが、これはAzureデータベースだと確信しています。何かが助けになるでしょう。
おかげで、ところで
USE [OST]
GO
/****** Object: StoredProcedure [mgt].[InsertPageSecurityMapping] Script Date: 3/30/2016 11:30:55 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [mgt].[UpdateAlerts]
(
@pkDistro int
,@intAlerts int
,@vchrCustomer varchar(100)
)
as
begin
--create a table variable of the unpivoted mgt.tblDistro table
DECLARE @unpvtDistroTemp TABLE
(
pkDistroID int,
vchrCustomer varchar(100),
intAlerts int
)
INSERT INTO @unpvtDistroTemp (pkDistroID, vchrCustomer, intAlerts)
(
SELECT pkDistroID, vchrCustomer, intAlerts
FROM
(SELECT pkDistroID, intComcast, intCableVision, intHearst, intCharter FROM mgt.tblDistro) mtd
UNPIVOT (intAlerts FOR vchrCustomer IN (intComcast, intCableVision, intHearst, intCharter)) as unpvtTable
)
--check to see if the alerts are a 1 or 0 and update the table
if @intAlerts = 1
begin
UPDATE @unpvtDistroTemp
SET intAlerts = 1
WHERE pkDistroID = @pkDistro AND @vchrCustomer
select 1
end
if @intAlerts = 0
begin
UPDATE @unpvtDistroTemp
set intAlerts = 0
WHERE pkDistroID = @pkDistro AND vchrCustomer = @vchrCustomer
select 0
end
UPDATE mgt.TblDistro
SET @vchrCustomer = (SELECT @vchrCustomer
FROM @unpvtDistroTemp
PIVOT
(MAX(intAlerts)
FOR vchrCustomer IN (intComcast, intCableVision, intHearst, intCharter)) as pvtTable
WHERE pkDistroID = @pkDistro)
end
GO
は、エラーがUNPIVOTに '選択' の周りにあると言っています。 –
WOW!愚かな間違い...私は最初のIFステートメントにbool lean式を入れるのを忘れていました。投稿して申し訳ありません。 –