Click here to Skip to main content
15,881,755 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL QUERY Pin
Blue_Boy13-Oct-07 1:50
Blue_Boy13-Oct-07 1:50 
GeneralRe: SQL QUERY Pin
Trustapple13-Oct-07 4:55
Trustapple13-Oct-07 4:55 
GeneralRe: SQL QUERY [modified] Pin
Blue_Boy13-Oct-07 5:17
Blue_Boy13-Oct-07 5:17 
GeneralRe: SQL QUERY Pin
Trustapple14-Oct-07 17:51
Trustapple14-Oct-07 17:51 
GeneralRe: SQL QUERY Pin
Blue_Boy15-Oct-07 11:32
Blue_Boy15-Oct-07 11:32 
QuestionSetting PRIMARY KEY using Alter Table Pin
Widgets13-Oct-07 0:02
Widgets13-Oct-07 0:02 
AnswerRe: Setting PRIMARY KEY using Alter Table Pin
GuyThiebaut13-Oct-07 0:40
professionalGuyThiebaut13-Oct-07 0:40 
AnswerRe: Setting PRIMARY KEY using Alter Table Pin
Mike Dimmick13-Oct-07 2:24
Mike Dimmick13-Oct-07 2:24 
Several problems:

- You haven't specified a default value for SampleField and have disallowed NULLs so the database doesn't know what value to give that field for existing rows in the table (it would normally use NULL but you've disallowed it);

- Even when you do add a default value or allow NULLs primary keys must be built on unique values, and every row in the table will then have the same value in that column;

- The SQL syntax for ALTER TABLE doesn't allow you to do both at the same time anyway;

- The SQL syntax for adding a primary key is:
ALTER TABLE tblSample
ADD CONSTRAINT PK_tblSample PRIMARY KEY
  ( SampleField )
PK_tblSample is the name I've given to the constraint, which you need if you later want to drop it. If using CREATE TABLE, you can set the primary key to a single column simply by stating PRIMARY KEY after the column definition, but the name is generated by SQL Server making it harder to use later.

You can define a primary key on a table that doesn't already have one by using the syntax above. You can create compound keys - keys consisting of multiple column values - by including all the key columns between the parentheses.


DoEvents: Generating unexpected recursion since 1991

GeneralRe: Setting PRIMARY KEY using Alter Table Pin
Widgets21-Oct-07 0:03
Widgets21-Oct-07 0:03 
QuestionDataGridView Filter Pin
udikantz12-Oct-07 22:13
udikantz12-Oct-07 22:13 
AnswerRe: DataGridView Filter Pin
GuyThiebaut12-Oct-07 22:35
professionalGuyThiebaut12-Oct-07 22:35 
GeneralRe: DataGridView Filter Pin
udikantz12-Oct-07 22:37
udikantz12-Oct-07 22:37 
QuestionSSRS embedded code and dynamic columns Pin
dove1112-Oct-07 9:08
dove1112-Oct-07 9:08 
AnswerRe: SSRS embedded code and dynamic columns [modified] Pin
pmarfleet12-Oct-07 9:53
pmarfleet12-Oct-07 9:53 
QuestionReg: SQL DB in Emergency Mode [modified] Very Urgent Pin
P.T.R.K12-Oct-07 7:20
P.T.R.K12-Oct-07 7:20 
AnswerRe: Reg: SQL DB in Emergency Mode [modified] Very Urgent Pin
Skanless12-Oct-07 8:49
Skanless12-Oct-07 8:49 
QuestionDynamic database pathways... Pin
new_phoenix12-Oct-07 6:59
new_phoenix12-Oct-07 6:59 
AnswerRe: Dynamic database pathways... Pin
Hesham Amin12-Oct-07 8:46
Hesham Amin12-Oct-07 8:46 
GeneralRe: Dynamic database pathways... Pin
new_phoenix15-Oct-07 10:41
new_phoenix15-Oct-07 10:41 
QuestionSQL statement on website, global password Pin
Cory Kimble12-Oct-07 6:57
Cory Kimble12-Oct-07 6:57 
AnswerRe: SQL statement on website, global password Pin
andyharman12-Oct-07 8:18
professionalandyharman12-Oct-07 8:18 
GeneralRe: SQL statement on website, global password Pin
Cory Kimble15-Oct-07 4:21
Cory Kimble15-Oct-07 4:21 
GeneralRe: SQL statement on website, global password Pin
andyharman15-Oct-07 8:29
professionalandyharman15-Oct-07 8:29 
Questiona problem about stackoverflow Pin
nibabug12-Oct-07 3:27
nibabug12-Oct-07 3:27 
AnswerRe: a problem about stackoverflow Pin
Pete O'Hanlon12-Oct-07 4:44
mvePete O'Hanlon12-Oct-07 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.