0

这是我试图创建的存储过程:

CREATE PROCEDURE [cih_owner].[UpdateDisplayOrder]
    @CbpTableName varchar (21), 
    @CbpObjId int,
    @CbpId int,
    @DisplayOrder int
AS
BEGIN
    IF (@CbpTableName = "CbpActivity")
    BEGIN
        UPDATE [cih_owner].[CbpActivity] SET DisplayOrder = @DisplayOrder WHERE Id = @CbpObjId AND CbpId = @CbpId
        ;
    END
END
GO

然而,一行写着: (@CbpTableName = "CbpActivity") 我得到 "CbpActivity" 了错误 下面的波浪线Invalid column name 'CbpActivity'

我要做的就是比较我发送到存储过程的字符串。

谢谢!

4

3 回答 3

1

您需要对字符串文字使用撇号而不是引号:

IF (@CbpTableName = 'CbpActivity')
于 2012-11-06T18:39:10.717 回答
0

您是否尝试过像这样修改"for '

CREATE PROCEDURE [cih_owner].[UpdateDisplayOrder]
    @CbpTableName varchar (21), 
    @CbpObjId int,
    @CbpId int,
    @DisplayOrder int
AS
BEGIN
    IF (@CbpTableName = 'CbpActivity')
    BEGIN
        UPDATE [cih_owner].[CbpActivity] SET DisplayOrder = @DisplayOrder WHERE Id = @CbpObjId AND CbpId = @CbpId
        GO
    END
END
GO
于 2012-11-06T18:39:47.497 回答
0

你应该使用单引号

IF (@CbpTableName = 'CbpActivity')

字符串在 SQL 中用单引号括起来

于 2012-11-06T18:39:49.810 回答