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

Autonumber field

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi all

I need to make a query with two fields one of which is supposed to be just an incrementing integer

I assume it supposed to look like this:

SELECT AutoNumber As Id, PrintLetter
From Letters

this code doesnt work, how do i create an autonumber field

Thanks
Alex
 
You cannot use AUTONUMBER in SQL Server. You can't define a column as Identity in SQL queries. You could execute a procedure like this. You'll need to supply data type and size of the PrintLetter column.

Create procedure PrintLetterQuery As

Create Table #t (RecID Int Identity(1,1), PrintLetter <data type>(<size>))

Insert #t (PrintLetter)
Select PrintLetter From Letter

Select * From #t
Go Terry

&quot;I'm not dumb. I just have a command of thoroughly useless information.&quot; - Calvin, of Calvin and Hobbes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top