Reputation:
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!
Upvotes: 0
Views: 114
Reputation: 26376
You should be using single quote
IF (@CbpTableName = 'CbpActivity')
String are enclosed in single quotes in SQL
Upvotes: 0
Reputation: 968
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
Upvotes: 0
Reputation: 32680
You need to use apostrophes instead of quotations for string literals:
IF (@CbpTableName = 'CbpActivity')
Upvotes: 1