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 2000 Forums
 SQL Server Development (2000)
 Stored Procedure Help

Author  Topic 

evanburen
Posting Yak Master

167 Posts

Posted - 2007-04-05 : 07:59:49
I'm writing a ASP.NET page that uses a stored procedure with a required input parameter. The input string could be one integer or a sting of them separated by commas. CompID is an int field in my database. When I have a list of compIDs, I'm getting an error because the parameter isn't formatted correctly as an integer. I'm getting confused on how to pass a string of numbers to a procedure which expects an Int. Thanks


'input parameter for the sproc
cmd.Parameters.Add("@CompID", SqlDbType.Int).Value = 12931,12937


CREATE PROCEDURE sp_BenchmarkCompanyTotal
@CompID Int
AS
SELECT CompID, CompanyName
FROM TCompanies
WHERE CompID IN (@CompID)
GO

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-05 : 08:03:12
Check these links:
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830[/url]
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6134[/url]
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-06 : 00:04:09
Also
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -