I have an SQL database that was an Access database. In a
few of the tables, in the Access database, I used an auto
number. When I converted it to SQL I noticed that there
is not an auto number data type. I was wondering if there
is an equivalent to Auto number in SQL or if there was any
way of replicating that data type.
Thanks,
Aaron ShoverCheck out Identity in Books Online.
"Aaron Shover" <ashover@.state.pa.us> wrote in message
news:079201c35a8e$35f79620$a401280a@.phx.gbl...
> I have an SQL database that was an Access database. In a
> few of the tables, in the Access database, I used an auto
> number. When I converted it to SQL I noticed that there
> is not an auto number data type. I was wondering if there
> is an equivalent to Auto number in SQL or if there was any
> way of replicating that data type.
> Thanks,
> Aaron Shover|||Aaron,
Refer 'IDENTITY' property in BooksOnLine.A sample is
CREATE TABLE products
(
pid int IDENTITY(1,1),
pname varchar (35),
)
GO
INSERT products VALUES('book')
GO
--
Dinesh.
SQL Server FAQ at
http://www.tkdinesh.com
"Aaron Shover" <ashover@.state.pa.us> wrote in message
news:079201c35a8e$35f79620$a401280a@.phx.gbl...
> I have an SQL database that was an Access database. In a
> few of the tables, in the Access database, I used an auto
> number. When I converted it to SQL I noticed that there
> is not an auto number data type. I was wondering if there
> is an equivalent to Auto number in SQL or if there was any
> way of replicating that data type.
> Thanks,
> Aaron Shover|||In SQL Server, it is called an Identity column.
Depending on how you are making your tables, you either
set IDENTITY to YES once you have set the column data
type to integer, or from script you define the table
something like
CREATE TABLE {tablename}
(
tablenameID int identity(1,1) primary key clustered,
.
.
.
)
Either way will give an auto-incremented table. Note
that you are able to set the starting value, and the
incremental jump amount independently. In that example
it starts at 1 and increments by 1 (pretty common).
Paladin
>--Original Message--
>I have an SQL database that was an Access database. In
a
>few of the tables, in the Access database, I used an
auto
>number. When I converted it to SQL I noticed that there
>is not an auto number data type. I was wondering if
there
>is an equivalent to Auto number in SQL or if there was
any
>way of replicating that data type.
>Thanks,
>Aaron Shover
>.
>
No comments:
Post a Comment