Oracle Sequence/Link 2 MS SQL SERVER 2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ruediger.michels@feltengmbh.de

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

  • Martijn Tonies

    #2
    Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

    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
    Upscene: Database tools for developers. Database tools for Oracle, PostgreSQL, InterBase, Firebird, SQL Server, MySQL, NexusDB, SQL Anywhere and Advantage Database. Auditing tools for databases. Test Data Generator tools for databases.

    My thoughts:

    Database development questions? Check the forum!



    Comment

    • Martijn Tonies

      #3
      Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

      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
      Upscene: Database tools for developers. Database tools for Oracle, PostgreSQL, InterBase, Firebird, SQL Server, MySQL, NexusDB, SQL Anywhere and Advantage Database. Auditing tools for databases. Test Data Generator tools for databases.

      My thoughts:

      Database development questions? Check the forum!



      Comment

      • Hagbard

        #4
        Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

        thx Martijn

        Comment

        • Hagbard

          #5
          Re: Oracle Sequence/Link 2 MS SQL SERVER 2005


          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
          Upscene: Database tools for developers. Database tools for Oracle, PostgreSQL, InterBase, Firebird, SQL Server, MySQL, NexusDB, SQL Anywhere and Advantage Database. Auditing tools for databases. Test Data Generator tools for databases.

          My thoughts:

          Database development questions? Check the forum!
          http://www.databasedevelopmentforum.com
          the link is between two ms-sql servers

          Comment

          • DA Morgan

            #6
            Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

            ruediger.michel s@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
            damorgan@x.wash ington.edu
            (replace x with u to respond)
            Puget Sound Oracle Users Group
            Oracle PL/SQL examples, syntax, DBMS packages, string, timestamp, substring, PHP code, and Javascript Code Reference Library (formerly known as Morgan's Library)

            Comment

            • Martijn Tonies

              #7
              Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

              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
              Upscene: Database tools for developers. Database tools for Oracle, PostgreSQL, InterBase, Firebird, SQL Server, MySQL, NexusDB, SQL Anywhere and Advantage Database. Auditing tools for databases. Test Data Generator tools for databases.

              My thoughts:

              Database development questions? Check the forum!



              Comment

              • Martijn Tonies

                #8
                Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

                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
                Upscene: Database tools for developers. Database tools for Oracle, PostgreSQL, InterBase, Firebird, SQL Server, MySQL, NexusDB, SQL Anywhere and Advantage Database. Auditing tools for databases. Test Data Generator tools for databases.

                My thoughts:

                Database development questions? Check the forum!



                Comment

                • Tony Rogerson

                  #9
                  Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

                  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" <damorgan@psoug .orgwrote in message
                  news:1164904167 .680393@bubblea tor.drizzle.com ...
                  ruediger.michel s@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
                  damorgan@x.wash ington.edu
                  (replace x with u to respond)
                  Puget Sound Oracle Users Group
                  www.psoug.org

                  Comment

                  • DA Morgan

                    #10
                    Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

                    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
                    damorgan@x.wash ington.edu
                    (replace x with u to respond)
                    Puget Sound Oracle Users Group
                    Oracle PL/SQL examples, syntax, DBMS packages, string, timestamp, substring, PHP code, and Javascript Code Reference Library (formerly known as Morgan's Library)

                    Comment

                    • Tony Rogerson

                      #11
                      Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

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

                      Comment

                      • Serge Rielau

                        #12
                        Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

                        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

                        Comment

                        • Erland Sommarskog

                          #13
                          Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

                          Tony Rogerson (tonyrogerson@s qlserverfaq.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, esquel@sommarsk og.se

                          Books Online for SQL Server 2005 at

                          Books Online for SQL Server 2000 at

                          Comment

                          • David Portas

                            #14
                            Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

                            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:
                            ITProToday.com is a leading online source of news, analysis and how-to's about the information technology industry.


                            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:

                            --

                            Comment

                            • Tony Rogerson

                              #15
                              Re: Oracle Sequence/Link 2 MS SQL SERVER 2005

                              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@sommars kog.sewrote in message
                              news:Xns988EAF2 CAD53EYazorman@ 127.0.0.1...
                              Tony Rogerson (tonyrogerson@s qlserverfaq.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, esquel@sommarsk og.se
                              >
                              Books Online for SQL Server 2005 at

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

                              Comment

                              Working...