Unix Technical Forum

SQLServer to Sybase conversion, please

This is a discussion on SQLServer to Sybase conversion, please within the Sybase forums, part of the Database Server Software category; --> The following SQL runs on SQLServer: select col1, sum( col2 ) from ( select col1, col2 from table1 union ...


Go Back   Unix Technical Forum > Database Server Software > Sybase

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 03:05 PM
Andy K
 
Posts: n/a
Default SQLServer to Sybase conversion, please

The following SQL runs on SQLServer:

select col1, sum( col2 ) from (
select col1, col2 from table1
union all
select col1, col2 from table2
) as sub
group by col1

but I can't get Sybase to recognise this as SQL.

How can accomplish the same thing in Sybase ?

Thanks
Andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 03:05 PM
Rob Verschoor
 
Posts: n/a
Default Re: SQLServer to Sybase conversion, please


This syntax, with 'derived tables' (aka. 'inline views') is supported by ASE
12.5.1 (which was released in October 2003). Earlier versions of ASE don't
support this syntax.

HTH,

Rob
-------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 12.5/12.0/11.5/11.0
and Replication Server 12.5

Author of "The Complete Sybase ASE Quick Reference Guide"
Online orders accepted at http://www.sypron.nl/qr

mailto:rob@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY
http://www.sypron.nl
Sypron B.V., P.O.Box 10695, 2501HR Den Haag, The Netherlands
-------------------------------------------------------------

"Andy K" <magiciandor@yahoo.com> wrote in message
news:e402c831.0311140709.6e2d712a@posting.google.c om...
> The following SQL runs on SQLServer:
>
> select col1, sum( col2 ) from (
> select col1, col2 from table1
> union all
> select col1, col2 from table2
> ) as sub
> group by col1
>
> but I can't get Sybase to recognise this as SQL.
>
> How can accomplish the same thing in Sybase ?
>
> Thanks
> Andy



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 03:05 PM
Rene van Leeuwen
 
Posts: n/a
Default Re: SQLServer to Sybase conversion, please

In article <e402c831.0311140709.6e2d712a@posting.google.com >, Andy K wrote:
> The following SQL runs on SQLServer:
>
> select col1, sum( col2 ) from (
> select col1, col2 from table1
> union all
> select col1, col2 from table2
> ) as sub
> group by col1
>
> but I can't get Sybase to recognise this as SQL.
>
> How can accomplish the same thing in Sybase ?
>


See Rob's answer, but this may be your work-around:

select col1, col2 into #table
from table1
insert into #table
select col1, col2 from table2
select col1, sum( col2 ) from #table
group by col1
go
drop table #table
go



--
___ _
| _ \___ _ _ ___//
| / -_) ' \/ -_)
|_|_\___|_||_\___|
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 05:27 AM.


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