MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
The Best Selling PC Migration Utility.
Go Back   Dev Shed ForumsDatabasesMS SQL Development
View Poll Results: AUTO INCREMENT
Good 0 0%
Better 1 100.00%
Best 0 0%
Voters: 1. You may not vote on this poll


Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old February 17th, 2004, 05:22 PM
stockholmpost stockholmpost is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 stockholmpost User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb Sql Auto_increment

Hi,
What am i doing wroung here!!! i got Error msg 156, !!! i can belive that.
1)
CREATE TABLE Butik (ButikID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Namn VARCHAR(30),
Gatuadress VARCHAR(30),
Postnummer VARCHAR(6),
Postadress VARCHAR(20),
Oppnar TIME,
Stanger TIME,
Helgoppen ENUM(’Y’, ’N’));
2)
CREATE TABLE Telefon (TelefonID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Nummer VARCHAR(20),
ButikID INT);
3)
CREATE TABLE Kunder (Kundnummer INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Fornamn VARCHAR(20),
Efternamn VARCHAR(20),
Gatuadress VARCHAR(20),
Postnummer VARCHAR(6),
Postadress VARCHAR(20));
4)
CREATE TABLE Filmer (FilmID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
Namn VARCHAR(40),
Kategori ENUM (’Drama’, ’Rysare’, ’Action’, ’Thriller’, ’Komedi’),
Regissor VARCHAR(40),
Huvudroll VARCHAR(40),
Ar YEAR,
Land VARCHAR(20),
Pris INT);
5)
CREATE TABLE Uthyrning(FilmID INT NOT NULL,
ButikID INT NOT NULL,
Kundnummer INT NOT NULL,
Uthyrning DATE,
Aterlamning DATE);

All this make me sick, i dont know where and what i did wroung. THNX DEV
asap
thnx

Reply With Quote
  #2  
Old February 17th, 2004, 06:48 PM
chichian chichian is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Las Vegas
Posts: 12 chichian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 49 m 17 sec
Reputation Power: 0
If you're using MS SQL (are you in the right forum?), then AUTOINCREMENT doesn't work. Instead, use IDENTITY(<start number>, <increment by>) as in "IDENTITY(5,1)" would start assigning ids at 5 and increment by one.

So one of your tables would something like:
Code:
CREATE TABLE Telefon (
   TelefonID INT NOT NULL IDENTITY(1,1),
   Nummer VARCHAR(20),
   ButikID INT
   CONSTRAINT PK_Telefon PRIMARY KEY CLUSTERED 
   (
        TelefonID
   ) ON [PRIMARY]
)


As far as the enumerations, I don't think MS SQL allows for enumeration types but I don't know for sure (I am new to sql in general and MS SQL especially).

Good luck. I hope this helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Sql Auto_increment


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway