Wednesday, March 28, 2012

Passing multiple values in 1 varchar variable in a stored proc

Although my earlier posts weren't "perfect," I tested my later posting prett
y
thoroughly in a sample db, and it produces the desired results. In addition,
the code shown is almost exactly the same code as shown at
http://www.aspfaq.com/show.asp?id=2248
which was reference by Aaron Bertrand in a thread very similar to this one.
http://www.microsoft.com/technet/co...94-b4fd1783d45e
So please explain to me how I am leading him "astray."
"Erland Sommarskog" wrote:

> ckeaton@.inergex.com (ckeaton@.inergex.com@.discussions.microsoft.com) writes
:
> Before we go the actual question, permit me to point out two things. Or
> three.
> 1) Don't name your stored procedures sp_something, the sp_ prefix is
> reserved for system stored procedures, and SQL Server first looks
> in master for procedures with names like this.
> 2) In SQL Server you use ' to quote strings. If the setting
> QUOTED_IDENTIFER is OFF, you can use " as string delimiter as well.
> This is very handy with nested strings, but alas, there is
> functionality in SQL Server only works if QUOTED_IDENTIFIER is ON,
> so best practice is to use ' only. Note that this setting is ON
> by default in many contexts.)
> 3) And since you appear to get away with this, I suspect that you use
> Enterprise Manager to edit your stored procedures. (EM has this
> setting off by default for some inexplicable reason.) EM is a very
> poor tool to edit stored procedures. You are better off using
> Query Analyzer.
>
> I am afraid that the answers from Mark Williams led you astray. And
> the posting from Celko equally less helpful, as he uses syntax that
> does not work on SQL Server. (But he claims it to be portable!)
> Anyway, the way to do this, is to use a function that unpacks the
> list into a table. I have a loooong article on this on my web site,
> but this link brings you directly to a solution:
> http://www.sommarskog.se/arrays-in-...ist-of-strings.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx
>Thank you Mark Williams for you thorough answers. Your final solution worke
d
perfectly! If you're ever in Rochester, look me up. I owe you a drink.
For the rest of you who were helpful, thank you as well. I will take all of
your advice to heart. I am relatively new to stored procedures on MS SQL
Server, and thank you for your advice.
For our "newbie"-slinging friend, --CELKO--; I hope you can more helpful in
the future. You seem to know what you're talking about, but it gets lost in
the white noise of your apparent hostility.
To all, Happy New Year.
"Mark Williams" wrote:
> Although my earlier posts weren't "perfect," I tested my later posting pre
tty
> thoroughly in a sample db, and it produces the desired results. In additio
n,
> the code shown is almost exactly the same code as shown at
> http://www.aspfaq.com/show.asp?id=2248
> which was reference by Aaron Bertrand in a thread very similar to this one
.
> http://www.microsoft.com/technet/co...94-b4fd1783d45e
> So please explain to me how I am leading him "astray."
> "Erland Sommarskog" wrote:
>sql

No comments:

Post a Comment