Re: Passing in a Parameter



thanks for that link! it was very helpful. but after i implemented the
articles ideas, i came across this solution:

DECLARE @Var AS VARCHAR(100)
SET @Var = '''Dan'', ''Mike'', ''Lisa'''
DECLARE @SQL AS varchar(1000)

SET @SQL = 'SELECT *
FROM ORDERS
WHERE
NAME IN (' + @Var + ')'

Exec(@SQL)




"Hugo Kornelis" wrote:

> On Thu, 28 Apr 2005 08:04:09 -0700, Kunkel wrote:
>
> >Hi All,
> >
> >I have a Stored Proc and would like to pass in a VARCHAR parameter. The
> >problem is that the query will need to use it in a IN clause...
> >
> >DECLARE @PARAM AS VARCHAR(20)
> >SET @PARAM = 'Dan', 'Mike', 'Lisa'
> >
> >SELECT *
> >FROM Orders
> >WHERE Name IN (@PARAM)
> >
> >is there a away around this?
>
> Hi Kunkel,
>
> Several. And they are all described and compared at
> http://www.sommarskog.se/arrays-in-sql.html
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
>
.



Relevant Pages

  • Re: Profiler Bug viewing trace flat file?
    ... Kalen Delaney, SQL Server MVP ... Run this code to create a trace capture of the RPC:Complete event: ... declare @error INT ... Now open the trace file in Profiler and you will see that the Textdata ...
    (microsoft.public.sqlserver.tools)
  • Re: function pointers vs direct calling in javascript
    ... scope tree to look for 'tempVar2' or for some other reason? ... Here is what I think of 'var', correct me if I am wrong. ... 'var' doesn't as such declare a variable. ... a property of the global object when the code executes. ...
    (comp.lang.javascript)
  • Re: Performance Issues With Query
    ... SQL Server MVP ... > DECLARE @Timestamp datetime ... > DECLARE @CallEventName varchar ... > UPDATE CallByCallYesterdayFinal SET Script = SUBSTRING(@Destination, ...
    (microsoft.public.sqlserver)
  • Re: MDIForm Parent/Child forms BEST Practice
    ... First i always create a public var of my main form (mdi parent) for easy ... access (yust declare it in a module and i the parent.load set the var to me) ... Private Sub frmMain_Closed(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem with SQL UDF
    ... DECLARE RLIB VARCHAR; ... DECLARE RVAR CHARDEFAULT ' '; ... In SQL reference, I found that, if not explicitly declared in a declare procedure statement, all arguments inside a variable will be considered of type INOUT, so I assumed that should run as is, but it's not. ...
    (comp.sys.ibm.as400.misc)