Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - - 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
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!!!!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 =

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



p.s please email me at

Jim Egan Posted on 2001-03-16 04:33:57.0Z
From: Jim Egan <>
Subject: Re: Dynamic SQL in Sybase SQL Server
Date: Thu, 15 Mar 2001 21:33:57 -0700
Message-ID: <>
References: <344D8BE93C33BD3700394D1685256A10.00394D2985256A10@webforums>
X-Newsreader: MicroPlanet Gravity v2.30
Newsgroups: sybase.public.sqlserver.nt
Lines: 7
Path: forums-1-dub!!
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