Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
oahu9872
Posting Yak Master
112 Posts |
Posted - 2005-08-16 : 12:13:34
|
| Does anyone know how I can autonumber a field in Microsoft SQL Server for something like Customer ID's? Thanks. |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2005-08-16 : 12:23:26
|
| Define it as a IDENTITY field.---------------------------EmeraldCityDomains.com |
 |
|
|
oahu9872
Posting Yak Master
112 Posts |
Posted - 2005-08-16 : 12:36:34
|
| Thanks. I looked up the Identity function in the Help section, and i was able to come up with this from it. (IDENTITY ( int [ , seed , increment ] ) AS SubscriberIDThe column name in my table is SubscriberID and has a type int. It does not give any errors, but the value in the row is null, so it didn't do any numbering. do you see anything i'm missing? |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2005-08-16 : 12:47:12
|
| What I meant was in your table definition or CREATE TABLE statement, to include the IDENTITY command so that the table structure is changed. The syntax you reference looks like you tried to use it in a SELECT statement.---------------------------EmeraldCityDomains.com |
 |
|
|
oahu9872
Posting Yak Master
112 Posts |
Posted - 2005-08-16 : 12:55:30
|
| In MS SQL Server, I could only pick "uniqueidentifier" not Identity. this is my code right now. i get an error saying there is a small syntax problem near identity. sSQL = sSQL & " values (IDENTITY ( int [ , 1 , 1 ] ) AS SubscriberID, '" & FullName & "', '" & PWD1 & "', '" & Email & "','" & Age & "','" & Gender & "','" & Promotions & "', 'YES', 'FW', Convert(varchar,getdate(),112), 'Good') " |
 |
|
|
oahu9872
Posting Yak Master
112 Posts |
Posted - 2005-08-16 : 13:53:47
|
| Ok, it works. I didn't realize at first what you were saying to do. Thanks for the help. |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-08-17 : 07:41:48
|
| "Email" is usually a pretty good Natural Key ...Jay White |
 |
|
|
|
|
|
|
|