Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to pass string value to stored procedure.....

Author  Topic 

gvmk27
Starting Member

44 Posts

Posted - 2012-02-28 : 10:53:57
Hi

I have s string parameter to the stored procedure (SP) like '10000004','10000101','10000005','10000106'. In the SP, I'm using IN keyword

but its not giving any result...if I execute as SQL its returning the correct results, below is the SP

ALTER PROCEDURE [dbo].[usp_Branch_ByRegionId_Get]
-- Add the parameters for the stored procedure here
@RegionId nvarchar(50)
AS
BEGIN

SELECT WB.BranchID, WB.BranchName
FROM WebBranch WB
INNER JOIN KUMON2000.dbo.Branch B ON B.BranchID = WB.BranchID
INNER JOIN KUMON2000.dbo.GMOffice GM ON GM.GMOfficeID = B.GMOfficeID
AND GM.RegionID IN (@RegionId)

END

if I execute as a SQL, it will run perfectly..


SELECT WB.BranchID, WB.BranchName
from WebBranch WB
INNER JOIN KUMON2000.dbo.Branch B ON B.BranchID = WB.BranchID
INNER JOIN KUMON2000.dbo.GMOffice GM ON GM.GMOfficeID = B.GMOfficeID
and GM.RegionID IN ('10000004','10000101','10000005','10000106')

Thanks for ur help in advance...

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-02-28 : 10:54:54
here's the arrays / lists bible for sql server.
http://www.sommarskog.se/arrays-in-sql.html

all your answers are there.

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2012-02-28 : 11:06:43
or you can use an xml payload that your sproc consumes. another option easier to manage

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -