Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Dynamic SQL in Sybase SQL Server

2 posts in Windows NT Last posting was on 2001-03-16 04:33:57.0Z
BenScott Posted on 2001-03-15 10:25:53.0Z
From: BenScott@halifax.co.uk
Date: Thu, 15 Mar 2001 05:25:53 -0500
Newsgroups: sybase.public.sqlserver.nt
Subject: Dynamic SQL in Sybase SQL Server
Message-ID: <344D8BE93C33BD3700394D1685256A10.00394D2985256A10@webforums>
Lines: 25
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub sybase.public.sqlserver.nt:1099
Article PK: 1087701

Hey all,

Im trying to create a bit of Dynamic SQL in a Sybase stored procedure, im
used to MS SQL Server so im not sure what im doing wrong in Sybase.
Heres my bit of code

declare @sql varchar(100)
declare @sql2 varchar(100)

Select @sql =
"""0001/100212"",""0001/100218"",""0001/100240"",""0001/100243"""

select @sql2 = 'select * from tablename where table_code in (' + @sql + ')'

Exec @sql2


now i would have thought this would have executed @sql2 and returned a
result set, but no :(. Any ideas?, idealy i will be passing in @SQL as a
paramenter.

Cheers

Ben

p.s please email me at BenScott@halifax.co.uk


Jim Egan Posted on 2001-03-16 04:33:57.0Z
From: Jim Egan <dbaguru@eganomics.com>
Subject: Re: Dynamic SQL in Sybase SQL Server
Date: Thu, 15 Mar 2001 21:33:57 -0700
Message-ID: <MPG.151b45a01cfa41de98b1ac@forums.sybase.com>
References: <344D8BE93C33BD3700394D1685256A10.00394D2985256A10@webforums>
Reply-To: eganjp@compuserve.com
X-Newsreader: MicroPlanet Gravity v2.30
Newsgroups: sybase.public.sqlserver.nt
Lines: 7
NNTP-Posting-Host: c1420400-b.hiland1.co.home.com 65.7.153.228
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1095
Article PK: 1087697

I believe this was already answered in one of the other newsgroups. Please do not cross
post your message.
--
Jim Egan [TeamSybase]
Senior Consultant
Sybase Professional Services

Get your free subscription to PowerTimes at http://www.powertimes.com