Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select into help

Status
Not open for further replies.

hvass

Programmer
Mar 16, 2002
192
0
0
GB
I am attempting to convert myself from MySQL to Sybase ...
and would appreciate your help ...

I am trying to specify autoincrement columns and primary keys etc... in a select into statemment

In Mysql:
Code:
create table myrank (rank int(8) unsigned not null autoincrement, primary key comp(cid,rank))
select
  cid,
  orddate,
  attribute1,
  attribute2
from mytable
order by cid,orddate desc;
Looking for the equivalent in Sybase.. and have tried adding the column definitions to the into statement without success...
Code:
select
  cid,
  orddate,
  attribute1,
  attribute2
into myrank (rank int(8) unsigned not null autoincrement, primary key comp(cid,rank))
from mytable
order by cid,orddate desc;
[/code

I am having to go through perl DBI ODBC to get to Sybase so unclear as to what version of Sybase

Thanks in advance.. including a point at the right bit of the Sybase manual online
 
It is called an identity column in sybase e.g.
Code:
select rank=identity(8)
,cid=id
,orddate=crdate
,attribute1=name 
into myrank
from sysobjects 
where id between 10 and 50

alter table myrank add primary key(cid,rank)

select * from myrank

drop table myrank
 
To get the sybase version just do
select @@version
 
Magic thanks PDreyer
Can get this to work when I use sysobjects table as in your example... but getting 'This function not supported with ODBC' when I try one of my tables... so when I get access to Sysbase will continue to experiment...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top