470,855 Members | 1,143 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

SqlServer2000: autonumbering records - how to ?

I created table with "id" field as "uniqueidentifier" (primary key).

I connect via ODBC from MS-Acces.
-->>> Don't know how to something like "Autonumber" in MS-Access.

Let me know If any trigger or something like this is required.
Please post some code of trigger if need.
Until now I have only developed some native MS-Access
databases. I hope there is some solution about "Autonumbering records"
in SQLServer.

SqlServer 2000, Access Xp.

Marek Bħbski

Jul 23 '05 #1
2 1382
autonumber = identity

look it up in the books on line for examples and more info

"netx" <us**********@go2.pl> wrote in message
news:42*********************@mamut2.aster.pl...
I created table with "id" field as "uniqueidentifier" (primary key).

I connect via ODBC from MS-Acces.
-->>> Don't know how to something like "Autonumber" in MS-Access.

Let me know If any trigger or something like this is required.
Please post some code of trigger if need.
Until now I have only developed some native MS-Access
databases. I hope there is some solution about "Autonumbering records"
in SQLServer.

SqlServer 2000, Access Xp.

Marek Bħbski

Jul 23 '05 #2
On Thu, 10 Mar 2005 13:59:10 +0100, netx wrote:
I created table with "id" field as "uniqueidentifier" (primary key).

I connect via ODBC from MS-Acces.
-->>> Don't know how to something like "Autonumber" in MS-Access.

(snip)

Hi Marek,

The equivalent of Access' autonumber in SQL Server is the IDENTITY
property. For instance, to generate a surrogate key for invoices, you
could use

CREATE TABLE Invoices (InvID int NOT NULL IDENTITY,
CustID int NOT NULL,
Period smallint NOT NULL,
-- other columns,
PRIMARY KEY (InvID),
UNIQUE (CustID, Period),
FOREIGN KEY (CustID) REFERENCES Customers,
FOREIGN KEY (Period) REFERENCES InvoicingPeriods
)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Richard | last post: by
2 posts views Thread by N. Graves | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.