Hi All
How can i create a stored procedure which can pass a parameter as a list.
Below is sample sp:
create procedure spxx (@.@.param1 varchar(100))
as
select * from tb1 where col1 = @.@.param1
When executing i like would like to be able to do this:
1. exec spxx 'John'
0r
2. exec spxx 'John', 'Mary', 'Susan'
Thank you in advance.http://www.aspfaq.com/2248
"MittyKom" <MittyKom@.discussions.microsoft.com> wrote in message
news:B4089DB0-3CA6-432E-BCC2-108BB5502D74@.microsoft.com...
> Hi All
> How can i create a stored procedure which can pass a parameter as a list.
> Below is sample sp:
> create procedure spxx (@.@.param1 varchar(100))
> as
> select * from tb1 where col1 = @.@.param1
> When executing i like would like to be able to do this:
> 1. exec spxx 'John'
> 0r
> 2. exec spxx 'John', 'Mary', 'Susan'
> Thank you in advance.
>|||You pass it as a string and split it inside the Stored Proc.
Check this out...
http://www.sommarskog.se/arrays-in-sql.html
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||MittyKom wrote:
> Hi All
> How can i create a stored procedure which can pass a parameter as a list.
> Below is sample sp:
> create procedure spxx (@.@.param1 varchar(100))
> as
> select * from tb1 where col1 = @.@.param1
> When executing i like would like to be able to do this:
> 1. exec spxx 'John'
> 0r
> 2. exec spxx 'John', 'Mary', 'Susan'
> Thank you in advance.
>
One method:
http://www.realsqlguy.com/?p=9|||>> How can I create a stored procedure which can pass a parameter as a list.
<<
This is a common newbie error. Which you did not bother to Google
before posting, did you? It immediately tells us that:
1) You do not know what a compiled program is, but expect SQL to be an
intrpreter.
2) You do not know what a parameter or understand the concept of a
scalar value.
3) You do not know that a table is the only data structure in SQL --
there are no lists!
The kludge you get in a newsgroup is dynamic SQL, with all the problems
that come with it. Hey, but a kludge is so much easier and faster than
an education, or even a Google search beforee posting!
We can also give you some pure SQL that split up a string. But that is
not the point; this is a bad design and poor programming. If you
really give a damn about doing it right, Please post DDL, so that
people do not have to guess what the keys, constraints, Declarative
Referential Integrity, data types, etc. in your schema are. Sample data
is also a good idea, along with clear specifications.|||And there is this one:
http://www.realsqlguy.com/?p=9
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
news:A220E647-6408-4428-A397-49E268158664@.microsoft.com...
> You pass it as a string and split it inside the Stored Proc.
> Check this out...
> http://www.sommarskog.se/arrays-in-sql.html
> --
> -Omnibuzz (The SQL GC)
> http://omnibuzz-sql.blogspot.com/
>|||Thank you all. Is there a way of doing this without using a function?
"Omnibuzz" wrote:
> You pass it as a string and split it inside the Stored Proc.
> Check this out...
> http://www.sommarskog.se/arrays-in-sql.html
> --
> -Omnibuzz (The SQL GC)
> http://omnibuzz-sql.blogspot.com/
>|||something like this?
if exists(
Select 1 from TKCalls.dbo.tblCalls
where DATEDIFF(mi, StartedTime, GETDATE()) <=30
AND left(cast(Icent_Num as varchar(20)),6) = ('962472')
)
SET @.COUNT_CALLS_REC_1 = 1
else
SET @.COUNT_CALLS_REC_1 = 0
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||This answer tells us
1) You have no real industrial programming experience
2) You do not understand how SQL is being used out in the field
3) You are ignorant, condescending and arrogant
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1151689463.194144.106580@.d56g2000cwd.googlegroups.com...
> This is a common newbie error. Which you did not bother to Google
> before posting, did you? It immediately tells us that:
> 1) You do not know what a compiled program is, but expect SQL to be an
> intrpreter.
> 2) You do not know what a parameter or understand the concept of a
> scalar value.
> 3) You do not know that a table is the only data structure in SQL --
> there are no lists!
> The kludge you get in a newsgroup is dynamic SQL, with all the problems
> that come with it. Hey, but a kludge is so much easier and faster than
> an education, or even a Google search beforee posting!
> We can also give you some pure SQL that split up a string. But that is
> not the point; this is a bad design and poor programming. If you
> really give a damn about doing it right, Please post DDL, so that
> people do not have to guess what the keys, constraints, Declarative
> Referential Integrity, data types, etc. in your schema are. Sample data
> is also a good idea, along with clear specifications.
>|||I have tried to ignore your reply, but it's still bothering me. I have gone
through a few of your replies in this newsgroup and they are not helpful.You
are not being forced to help us here. So please if you are willing to help,
do so without all these stupid comments. Also if you are a programmer, it
does not mean that everyone is a programmer in this newsgroup. Cheers.
"--CELKO--" wrote:
> This is a common newbie error. Which you did not bother to Google
> before posting, did you? It immediately tells us that:
> 1) You do not know what a compiled program is, but expect SQL to be an
> intrpreter.
> 2) You do not know what a parameter or understand the concept of a
> scalar value.
> 3) You do not know that a table is the only data structure in SQL --
> there are no lists!
> The kludge you get in a newsgroup is dynamic SQL, with all the problems
> that come with it. Hey, but a kludge is so much easier and faster than
> an education, or even a Google search beforee posting!
> We can also give you some pure SQL that split up a string. But that is
> not the point; this is a bad design and poor programming. If you
> really give a damn about doing it right, Please post DDL, so that
> people do not have to guess what the keys, constraints, Declarative
> Referential Integrity, data types, etc. in your schema are. Sample data
> is also a good idea, along with clear specifications.
>