Unix Technical Forum

How to pass variables to select statement

This is a discussion on How to pass variables to select statement within the Sybase forums, part of the Database Server Software category; --> I have following statement in my stored procedure. From first two rows I can see the values for variables. ...


Go Back   Unix Technical Forum > Database Server Software > Sybase

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 03:42 PM
crasho2001
 
Posts: n/a
Default How to pass variables to select statement

I have following statement in my stored procedure. From first two rows I
can see the values for variables.

"where ce = @ce" is also working. But " (id not like "{@bc,%" or id not like
"{%,@bc,%" or id not like "%,@bc}") " is not working.



How can I pass @bc to " (id not like "{@bc,%" or id not like "{%,@bc,%" or
id not like "%,@bc}") " .....



select @ce

select @bc

select bs,ce,bc,id from int where ce = @ce

having(id not like "{@bc,%" or id not like "{%,@bc,%" or id not like
"%,@bc}")


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 03:42 PM
Karl Ritter
 
Posts: n/a
Default Re: How to pass variables to select statement

Take @bc out of the quotes. Ex:

1> declare @bc varchar(5)
2> select @bc = "sys"
3> select count(*) from master..sysobjects where name like @bc+'%'
4> go
(1 row affected)

-----------
52

(1 row affected)
1>


"crasho2001" <crasho2001@yahoo.com> wrote in message
news:bemedi$bjs$1@newstree.wise.edt.ericsson.se...
> I have following statement in my stored procedure. From first two rows I
> can see the values for variables.
>
> "where ce = @ce" is also working. But " (id not like "{@bc,%" or id not

like
> "{%,@bc,%" or id not like "%,@bc}") " is not working.
>
>
>
> How can I pass @bc to " (id not like "{@bc,%" or id not like "{%,@bc,%" or
> id not like "%,@bc}") " .....
>
>
>
> select @ce
>
> select @bc
>
> select bs,ce,bc,id from int where ce = @ce
>
> having(id not like "{@bc,%" or id not like "{%,@bc,%" or id not like
> "%,@bc}")
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:57 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com