Daniel,
I'm a bit worried about the syntax you show. Your charindex is looking for
AlternateGroup not in it - and I can't quite work out where it's looking for
it - possibly in ',)'. Also I don't recognise the IN construct in the
context. When you say a variable, do you mean a local variable in your
program? If so, you should be able to build your SQL statement in a variable
and this would enable you to include the contents of another variable -
which should appear as a literal in the generated statement.
e.g. (rough example not syntactically correct)
dim strSQL
strSQL = "SELECT CASE charindex('" & AlternateGroup &"', colname)"
strSQL = strSQL & "WHEN.............
strSQL is then passed as a parameter to an ExecuteSQL method or similar.
hth
Charles
> -----Original Message-----
> From: Daniel Vaz [SMTP:[Email Address Removed] Sent: Thursday, September 11, 2003 2:08 PM
> To: Long Charles (EHUK); [Email Address Removed] Subject: Re: CHARINDEX
>
> Charles,
>
> The result_expression after THEN in a CASE statemement
>
> how can I return a expression with a variable appended to it? This is a
> querry inside ASP. Code is below; selectedGroupID is actually a variable
> and
> in the else part I'd like to concatenate a comma into it.
>
> "CASE CharIndex(AlternateGroup, ',') " &_
> " WHEN NULL THEN 'selectedGroupID IN (AlternateGroup)' " &_
> " ELSE 'selectedGroupID' & ',' & 'IN (AlternateGroup)' " &_
> "END ) .... "
>
>
> Daniel
>
>
>
> "Long, Charles (EHUK)" wrote:
>
> > Returns zero
> >
> > > -----Original Message-----
> > > From: Daniel Vaz [SMTP:[Email Address Removed] > > Sent: Thursday, September 11, 2003 1:03 PM
> > > To: LazyDBA.com Discussion
> > > Subject: CHARINDEX
> > >
> > > Hello everyone,
> > >
> > > what does charindex return when an expression is not found in another?
> > > (Not a case of exp1 or exp2 being null). Will that be -1 or is it
> still
> > > NULL? BOL doesn't say anything
> > >
> > > thanks.
> > >
> > > Daniel
> > >
> > >
> > > ---------------------------------------------------------------------
> > > TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> > > To unsubscribe, e-mail: mssqldba-[Email Address Removed] > > For additional commands, e-mail: mssqldba-[Email Address Removed]MS Sql Server LazyDBA home page