Doubt in Stored procedure
-
I written strored procedure as below create procedure testProc @param varchar(100) as select * from authors where au_id in (@param) when i, execute this with following parameters, it gives me error. I execute it like this.. exec testProc('''2104206'',''123''') Regards PVC :sigh:
-
I written strored procedure as below create procedure testProc @param varchar(100) as select * from authors where au_id in (@param) when i, execute this with following parameters, it gives me error. I execute it like this.. exec testProc('''2104206'',''123''') Regards PVC :sigh:
parasu_516 wrote:
exec testProc('''2104206'',''123''')
Change this to exec testProc('2104206','123') How can you pass two values to procedure when the procedure accepts only one ?:confused: http://w3hearts.com/articles/6/[^]
printf("Navaneeth!!") www.w3hearts.com
-
parasu_516 wrote:
exec testProc('''2104206'',''123''')
Change this to exec testProc('2104206','123') How can you pass two values to procedure when the procedure accepts only one ?:confused: http://w3hearts.com/articles/6/[^]
printf("Navaneeth!!") www.w3hearts.com
Actually you need to change it to be exec testProc('2104206,123') If you look at what the SP is trying to do he wants to be able to pass in a range of values and return those details which are in the LIST of items as a single parametr. Now I'm not even going to get started on WHY this is dangerous for security - but this will make it work...... Mark.
-
Actually you need to change it to be exec testProc('2104206,123') If you look at what the SP is trying to do he wants to be able to pass in a range of values and return those details which are in the LIST of items as a single parametr. Now I'm not even going to get started on WHY this is dangerous for security - but this will make it work...... Mark.
Correct me if I am wrong but wont't the in operator have problems with a varchar string that happens to have commas? http://www.projectdmx.com/tsql/sqlarrays.aspx You might also want to consider dynamic sql. I have a feeling that on a lot of records you could get better performance.