Reputation: 393
HI,
I have an insert statement in a Stored Procedure that requires the value data to be a combination of text and variables/inputs. However my SQL Manager is giving an error on this 'camp' value when trying to compile it.
Here is the statement as it currently exists;
BEGIN TRAN
INSERT INTO TBL_DONATIONS ([donations_MemberID], [donation_Ref], [donations_Debit]) VALUES (@tmp_Id, "camp"+@tmp_Id+"/Key"+@tmp_IDENTITY, @tmp_Pledge)
COMMIT
I imagine its probably a case of me using the wrong format for concatenating the parts forming '"camp"+@tmp_Id+"/Key"+@tmp_IDENTITY' ???????
Any help greatly welcomed.
Thanks!
Upvotes: 0
Views: 449
Reputation: 21660
I think you must use ' instead of ""
EDIT: If you want to "" for values you have to
SET QUOTED_IDENTIFIER OFF
Upvotes: 3
Reputation: 170
What's the exact error you're getting?
Without further information, you may need to cast the following variables, because the naming convention you use would lead me to believe they are integers, and you are concatenating them with strings:
Try this: 'camp' + CAST(@tmp_Id as varchar) + '/Key' + CAST(@tmp_IDENTITY as varchar)
Upvotes: 3
Reputation:
You need to prepare the values before you stick them into the VALUES clause, or change it to an INSERT INTO ... SELECT ... query. The latter will be easier.
EDIT: And use single-quotes, not double-quotes.
Upvotes: 1