0

This is my stored procedure I am trying to create:

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

However, in line that reads: (@CbpTableName = "CbpActivity") I get squigglies under "CbpActivity" with the error Invalid column name 'CbpActivity'

All I am trying to do is compare a string that I sent to the stored procedure.

Thanks!

0

3 Answers 3

1

You need to use apostrophes instead of quotations for string literals:

IF (@CbpTableName = 'CbpActivity')
Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried to modified the " for ' like this:

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

1 Comment

Do you think the GO really still belongs in the middle of the procedure?
0

You should be using single quote

IF (@CbpTableName = 'CbpActivity')

String are enclosed in single quotes in SQL

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.