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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create sequence in SQL-SERVER 1

Status
Not open for further replies.

kingz2000

Programmer
May 28, 2002
304
DE
Hi,

I have a table with, say, 10 Columns, the primary key of the table defines itself by the first 3 columns(A,B & C,say).

I would like to add datasets to the table incrementing the values of columns A,B and C.

Now, with Oracle, I would use the Create Sequence command. How do I get around this problem with SQL-Server, since this command doesn't exist here????

Thanks in advance.
 
Can you post an example of a few rows in how you want the data to look?
 
The table looks like the following.

A B C D E F .....
-------------------------------------------------------
123 1 0 xde200 Y Y
146 2 1 xde300 Y N
147 1 1 xde564 N N


The Columns A,B AND C together make the primary key!! I want to add extra datasets to the existing table, this mainly concerns the column D. I am merely wanting to satisfy the tables requirements by inserting non-existing numbers for A,B,C.
What I wanted to do, is to insert 0 fpr A & B, and have an incremented value for C..

You know what I mean?

 
No, I don't understand. Is this what you want? (Say this table is ordered sequentially for display purposes).


Code:
A     B     C
---  ---    ---
13   6      0
72   3      1
45   9      2
8    44     3

A & B would accept values entered by the user, and C would auto-increment by SQL Server? If that's what you want, you just need to make C an "Identity" column. But then you don't really need a primary key to also cover A & B.

Or do you want something more like:

Code:
A     B     C
---   ---   ---
0     0     0
0     0     1
0     0     2
0     0     3
0     1     0
0     2     1
0     3     2
0     4     3
1     0     0
etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top