471,092 Members | 1,111 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

Oracle Sequence/Link 2 MS SQL SERVER 2005

hi,

1. is there a statement in ms sql, what creates a sequence? cant find
anything in web :-(
-oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLE
CACHE 20;
-ms sql: ???

2. hwo do i create a link to another ms-sql database

thx a lot need help, urgend :-)

Nov 30 '06 #1
14 6238
2. hwo do i create a link to another ms-sql database
From one MS SQL to another MS SQL server? Or database?
--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Nov 30 '06 #2
1. is there a statement in ms sql, what creates a sequence? cant find
anything in web :-(
-oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLE
CACHE 20;
-ms sql: ???
Microsoft SQL Server doesn't have sequences. It does have some sort
of auto-increment integer thingy for columns, check out "identity" in the
documentation.
--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Nov 30 '06 #3
thx Martijn

Nov 30 '06 #4

Martijn Tonies schrieb:
2. hwo do i create a link to another ms-sql database

From one MS SQL to another MS SQL server? Or database?
--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
the link is between two ms-sql servers

Nov 30 '06 #5
ru**************@feltengmbh.de wrote:
hi,

1. is there a statement in ms sql, what creates a sequence? cant find
anything in web :-(
-oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLE
CACHE 20;
-ms sql: ???

2. hwo do i create a link to another ms-sql database

thx a lot need help, urgend :-)
The only other databases that have abilities similar to those of
an Oracle SEQUENCE are DB2 and Informix (only the most recent release).
--
Daniel A. Morgan
University of Washington
da******@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Nov 30 '06 #6
the link is between two ms-sql servers
Set up a "Linked Server", check the documentation for that. It's really
easy to do :)
--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Nov 30 '06 #7
1. is there a statement in ms sql, what creates a sequence? cant find
anything in web :-(
-oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLE
CACHE 20;
-ms sql: ???

2. hwo do i create a link to another ms-sql database

thx a lot need help, urgend :-)

The only other databases that have abilities similar to those of
an Oracle SEQUENCE are DB2 and Informix (only the most recent release).
And InterBase, Firebird, PostgreSQL, Mimer, ThinkSQL and probably some
others that
I don't know about :-)
btw, SEQUENCE is in the SQL 2003 standard.
--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Nov 30 '06 #8
The only other databases that have abilities similar to those of
an Oracle SEQUENCE are DB2 and Informix (only the most recent release).
What about ROWNUMBER() in SQL Server 2005 and PARTITION??

--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"DA Morgan" <da******@psoug.orgwrote in message
news:11***************@bubbleator.drizzle.com...
ru**************@feltengmbh.de wrote:
>hi,

1. is there a statement in ms sql, what creates a sequence? cant find
anything in web :-(
-oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLE
CACHE 20;
-ms sql: ???

2. hwo do i create a link to another ms-sql database

thx a lot need help, urgend :-)

The only other databases that have abilities similar to those of
an Oracle SEQUENCE are DB2 and Informix (only the most recent release).
--
Daniel A. Morgan
University of Washington
da******@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org

Dec 1 '06 #9
Tony Rogerson wrote:
>The only other databases that have abilities similar to those of
an Oracle SEQUENCE are DB2 and Informix (only the most recent release).

What about ROWNUMBER() in SQL Server 2005 and PARTITION??
Totally different capabilities.

A sequence is not tied to a table: It is an independent object.

One can use a sequence to number count by any increment positive or
negative, assign the values to one table or to multiple tables, and
to repeatedly cycle through a fixed set of numbers (min to max and
back to min), and much more.

Maybe in SQL Server 2009?
--
Daniel A. Morgan
University of Washington
da******@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Dec 1 '06 #10
Oh - you mean SQL Server 2007? Remember Mark Souza committed themselves to a
2 year release cycle....

If I sat down and worked it out then what we have now in terms of CTE's,
table structures, triggers I could do it - sadly, no time [at mo].

--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"DA Morgan" <da******@psoug.orgwrote in message
news:11***************@bubbleator.drizzle.com...
Tony Rogerson wrote:
>>The only other databases that have abilities similar to those of
an Oracle SEQUENCE are DB2 and Informix (only the most recent release).

What about ROWNUMBER() in SQL Server 2005 and PARTITION??

Totally different capabilities.

A sequence is not tied to a table: It is an independent object.

One can use a sequence to number count by any increment positive or
negative, assign the values to one table or to multiple tables, and
to repeatedly cycle through a fixed set of numbers (min to max and
back to min), and much more.

Maybe in SQL Server 2009?
--
Daniel A. Morgan
University of Washington
da******@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org

Dec 2 '06 #11
Ruediger,

How is the sequence used in the app?
While it is true that sequences are divorced from tables teh majority of
usages that I know of is for one of two purposes:
* Generate unique value across the database. If that's the case I would
look at GUID.
* Generate an abstract primary key for a specific table (or many tables,
but without actual requirement for x-database uniqueness).
In that case IDENTITY columns are the way to go.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Dec 2 '06 #12
Tony Rogerson (to**********@sqlserverfaq.com) writes:
Oh - you mean SQL Server 2007? Remember Mark Souza committed themselves
to a 2 year release cycle....
Mark Souza? You are probably thinking of Paul Flessner.
If I sat down and worked it out then what we have now in terms of CTE's,
table structures, triggers I could do it - sadly, no time [at mo].
Itzik Ben-Gan has come up with an idea where you us an table with a single
identity column. You have a stored procedure that either starts a
transaction, or if a transaction is already in progress, it issues a
SAVE TRANSACTION. The procedure then inserts a row into the table and
retrieves the identity value with scope_identity(). Finally it rolls
back the transaction, either entirely or to the savepoint. Thus, table
is always empty, but it still produces a growing sequence. Since the table
is locked for only short duration, the concurrency is good.

A fairly convoluted solution, and likely to be less efficient than what
they have on Oracle.

Then again, in many cases a plain IDENTITY column will do.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 3 '06 #13
Erland Sommarskog wrote:
Itzik Ben-Gan has come up with an idea where you us an table with a single
identity column. You have a stored procedure that either starts a
transaction, or if a transaction is already in progress, it issues a
SAVE TRANSACTION. The procedure then inserts a row into the table and
retrieves the identity value with scope_identity(). Finally it rolls
back the transaction, either entirely or to the savepoint. Thus, table
is always empty, but it still produces a growing sequence. Since the table
is locked for only short duration, the concurrency is good.

A fairly convoluted solution, and likely to be less efficient than what
they have on Oracle.
Itzik's article is here:
http://www.sqlmag.com/Article/Articl...ver_48165.html

It does overcome some of the disadvantages of an IDENTITY column and
I've used variations of it very successfully. I am looking forward to
the day when we get an engine-level implementation of sequences and I
never have to use an IDENTITY column again.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--

Dec 3 '06 #14
Good stuff.

Nope - it was Mark Souza at TechEd / IT Forum last year; there is a press
release somewhere.

--
Tony Rogerson
SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson - technical commentary from a SQL
Server Consultant
http://sqlserverfaq.com - free video tutorials
"Erland Sommarskog" <es****@sommarskog.sewrote in message
news:Xn**********************@127.0.0.1...
Tony Rogerson (to**********@sqlserverfaq.com) writes:
>Oh - you mean SQL Server 2007? Remember Mark Souza committed themselves
to a 2 year release cycle....

Mark Souza? You are probably thinking of Paul Flessner.
>If I sat down and worked it out then what we have now in terms of CTE's,
table structures, triggers I could do it - sadly, no time [at mo].

Itzik Ben-Gan has come up with an idea where you us an table with a single
identity column. You have a stored procedure that either starts a
transaction, or if a transaction is already in progress, it issues a
SAVE TRANSACTION. The procedure then inserts a row into the table and
retrieves the identity value with scope_identity(). Finally it rolls
back the transaction, either entirely or to the savepoint. Thus, table
is always empty, but it still produces a growing sequence. Since the table
is locked for only short duration, the concurrency is good.

A fairly convoluted solution, and likely to be less efficient than what
they have on Oracle.

Then again, in many cases a plain IDENTITY column will do.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Dec 5 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Uma | last post: by
1 post views Thread by Mike Landis | last post: by
28 posts views Thread by prunoki | last post: by
2 posts views Thread by egoldthwait | last post: by
1 post views Thread by Magnus Flisberg | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.