SQL server syntax
am 03.03.2005 14:23:07 von MikeD
Sorry for posting here but I can't find the SQL server NG.
What is the correct syntax for using Like in a select with a variable in a
stored procedure?
My stored procedure is:
Select fields from Table where ClientAccess = @Client
I would like
Select fields from Table where ClientAccess Like '%@Client%'
but that of course doesn't work. How do I write this select?
Thanks
Mike
Re: SQL server syntax
am 03.03.2005 14:53:34 von reb01501
Mike D wrote:
> Sorry for posting here but I can't find the SQL server NG.
microsoft.public.sqlserver.programming
>
> What is the correct syntax for using Like in a select with a variable
> in a stored procedure?
>
> My stored procedure is:
>
> Select fields from Table where ClientAccess = @Client
>
> I would like
> Select fields from Table where ClientAccess Like '%@Client%'
> but that of course doesn't work. How do I write this select?
>
Select fields from Table where ClientAccess Like '%' + @Client + '%'
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Re: SQL server syntax
am 03.03.2005 15:15:09 von MikeD
thanks
"Bob Barrows [MVP]" wrote:
> Mike D wrote:
> > Sorry for posting here but I can't find the SQL server NG.
> microsoft.public.sqlserver.programming
>
> >
> > What is the correct syntax for using Like in a select with a variable
> > in a stored procedure?
> >
> > My stored procedure is:
> >
> > Select fields from Table where ClientAccess = @Client
> >
> > I would like
> > Select fields from Table where ClientAccess Like '%@Client%'
> > but that of course doesn't work. How do I write this select?
> >
>
> Select fields from Table where ClientAccess Like '%' + @Client + '%'
>
> HTH,
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
>