Monday, March 12, 2012

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 :-)

Quote:

Originally Posted by

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|||

Quote:

Originally Posted by

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|||thx Martijn|||Martijn Tonies schrieb:

Quote:

Originally Posted by

Quote:

Originally Posted by

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|||ruediger.michels@.feltengmbh.de wrote:

Quote:

Originally Posted by

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
damorgan@.x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org|||

Quote:

Originally Posted by

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|||1. is there a statement in ms sql, what creates a sequence? cant find

Quote:

Originally Posted by

Quote:

Originally Posted by

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|||The only other databases that have abilities similar to those of

Quote:

Originally Posted by

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" <damorgan@.psoug.orgwrote in message
news:1164904167.680393@.bubbleator.drizzle.com...

Quote:

Originally Posted by

ruediger.michels@.feltengmbh.de wrote:

Quote:

Originally Posted by

>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
damorgan@.x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org

|||Tony Rogerson wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

>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
damorgan@.x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org|||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" <damorgan@.psoug.orgwrote in message
news:1164990743.577953@.bubbleator.drizzle.com...

Quote:

Originally Posted by

Tony Rogerson wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

>>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
damorgan@.x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org

|||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/F.../Forum2006.html|||Tony Rogerson (tonyrogerson@.sqlserverfaq.com) writes:

Quote:

Originally Posted by

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.

Quote:

Originally Posted by

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, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Erland Sommarskog wrote:

Quote:

Originally Posted by

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/Artic...rver_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/...US,SQL.90).aspx
--|||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" <esquel@.sommarskog.sewrote in message
news:Xns988EAF2CAD53EYazorman@.127.0.0.1...

Quote:

Originally Posted by

Tony Rogerson (tonyrogerson@.sqlserverfaq.com) writes:

Quote:

Originally Posted by

>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.
>

Quote:

Originally Posted by

>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, esquel@.sommarskog.se
>
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

No comments:

Post a Comment