Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 change oracle sql query to MSSQL 7.0

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-23 : 10:00:12
David writes "I have Oracle query that returns me next available id from the system table DUAL. Does ms sql has anything like this and how I
can convert this query from Oracle to MSSQL
Here is ther query.
"select MYID.NextVal from DUAL"

Thanks,
David"

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2002-08-23 : 12:21:42
You are not selecting anything from the table dual. Rather you are requesting the next value from a sequence named Myid.
SQL server does not support sequences, instead you can set the identity attribute for a column. An identity attribute means that SQL server will generate a unique value for that column when a new record is inserted. After the insert you can retrieve the newly inserted value by using the statement

select @@identity

Read more in Books On Line (create table)

Go to Top of Page
   

- Advertisement -