0

I faced to a huge problem when i coding some stored procedure. How to combine some string to sql string in stored procedure???

This is what i did upto now.

@WhereCondition = ' WHERE id = 102 '
DECLARE recoredSet CURSOR FOR
        SELECT SUM(Amount) as AmountSum FROM sale + @WhereCondition
OPEN recoredSet

--After above code I wrote fetch commands and it has no any problem.

In above code, @WhereCondition is assinged some value.
Eg: @WhereCondition = ' WHERE id = 5 '

But the problem is plus mark (+) is not supported. If Plus mark is not there, the code is working well.
My Problem is how to combined some string to a sql string like above code. I put and sign (&) instead of plus mark. But it doesnt work.

3
Contributors
5
Replies
21
Views
4 Years
Discussion Span
Last Post by C#Jaap
0

It depends on database you are using. When you use an Oracle database you should use || (double pipe) to concat, + can be used with SQL Server and for MySQL you should use Concat('A', 'B')....

Edited by C#Jaap

0

im using sql server 2005. It is not supported CONCAT command....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.