I started database programming yesterday. I wanted to set a ID column as auto increment and it tells me to set it as the primary key. However after looking at the columns, I realised there is no primary key column. I suspect this database management tool in visual studio is not a full blown one and I need to use other program to edit this database?
            Asked
            
        
        
            Active
            
        
            Viewed 1,042 times
        
    0
            
            
         
    
    
        user3398315
        
- 331
- 6
- 17
- 
                    Sorry the picture turn out to be very small. I think you need to open it in new tab to see the picture – user3398315 Jul 29 '14 at 11:45
- 
                    3is this really MySQL? then why not add tags appropriately ... anyway: your screeny looks more like MSSQL! Do you want to achieve this via GUI or is TSQL-command ok for you? – Jul 29 '14 at 11:45
- 
                    sorry this is in visual studio (server explorer). I am confused. My mistake-mySQL is the command I send – user3398315 Jul 29 '14 at 11:47
- 
                    c'mon ... your error-message is pretty clear: you need to make your auto increment a primary key as well ... – Jul 29 '14 at 11:51
- 
                    [MySQL](http://en.wikipedia.org/wiki/MySQL) and [MS SQL](http://en.wikipedia.org/wiki/Microsoft_SQL_Server) are two different things. – Corak Jul 29 '14 at 11:53
2 Answers
1
            Right click left of the ID row (on the square) and use the option "set primary key" I believe that this should be possible but i'm not quite clear on what program you use.
You could always resort to SQL statements:
ALTER TABLE *table name* ADD PRIMARY KEY(ID);
 
    
    
        Vincent
        
- 1,497
- 1
- 21
- 44
0
            
            
        In Server Explorer expand the Tables node. After that double-click the table name. In the editor window right-click the column name and select Set Primary Key. For a compound key you must multi-select the columns and right-click.
If that works there should be a little key that appears next to it.
If you're still stuck this just about covers it https://www.youtube.com/watch?v=ZC8h5OChZLg
 
    
    
        Red
        
- 129
- 11
