必须声明标量变量“ @LocationId”

时间:2018-10-25 19:34:03

标签: sql sql-server tsql

public class Start1
{
  public EventHandler FrameAcquired
  {
    add 
    {
      this.camera.FrameAcquired += value;
    }
    remove
    {
      this.camera.FrameAcquired -= value;
    }
}

当我尝试在SQL中运行报告时,是否一直收到此错误消息?有什么想法吗?

2 个答案:

答案 0 :(得分:1)

问题是您必须首先定义1.0。 尝试在您的代码块前面添加:

LocationId

答案 1 :(得分:0)

在运行以下主查询之前,您需要声明@locationID:

declare @LocationId int = 10;
SELECT * FROM dbo.vwAlarmAssetGroupLocationReport
WHERE (LocationID = CAST(COALESCE(@LocationId, LocationId) AS uniqueidentifier) OR TopLocationId = CAST(COALESCE(@LocationId, TopLocationId) AS uniqueidentifier))
AND DateCreated Between '2018-10-23' AND '2018-10-25'
AND AssetGroupId = '8E99BAFB-739A-E411-B54B-40F2E9985B7A'
ORDER BY DateCreated

还请注意,BETWEEN关键字后的AND关键字不应放在引号中。