Click here to Skip to main content
15,890,741 members
Home / Discussions / Database
   

Database

 
GeneralRe: Date format in sql Pin
imnotso#10-Dec-07 0:54
imnotso#10-Dec-07 0:54 
QuestionMS Exchange connection? Pin
Mr.Kode9-Dec-07 22:27
Mr.Kode9-Dec-07 22:27 
Questionhow to avoid data redundancy in insert query? Pin
kssknov9-Dec-07 20:50
kssknov9-Dec-07 20:50 
GeneralRe: how to avoid data redundancy in insert query? Pin
Tobias Schoenig9-Dec-07 21:50
Tobias Schoenig9-Dec-07 21:50 
GeneralRe: how to avoid data redundancy in insert query? Pin
kssknov16-Dec-07 20:15
kssknov16-Dec-07 20:15 
GeneralRe: how to avoid data redundancy in insert query? Pin
SimulationofSai9-Dec-07 22:33
SimulationofSai9-Dec-07 22:33 
GeneralRe: how to avoid data redundancy in insert query? Pin
Colin Angus Mackay10-Dec-07 0:07
Colin Angus Mackay10-Dec-07 0:07 
GeneralRe: how to avoid data redundancy in insert query? Pin
supercat912-Dec-07 9:49
supercat912-Dec-07 9:49 
The field should either be a primary key or, or should be associated with a unique index. If a unique index exists for a field (or if it's a primary key, which is effectively a special type of unique index) then any attempt to add a record that already exists is guaranteed to fail. If two attempts are made simultaneously to add the same record, only one will succeed. In that regard, this approach is much better than the approach others here suggested of querying first to see if the record exists (two clients could both check for a record and discover it doesn't yet exist, and then both add it).

There are few stylistic issues to consider:

-1- If the record already exists, checking before doing the insert will avoid having a thrown exception except in the case where two clients attempt to add the same value simultaneously. Code must be prepared to handle the exception even if it checks before the insert, but avoiding the insert will probably be faster than attempting it and having it fail

-2- If the record does not exist, checking the database for it will take a little time; adding the record without pre-checking would probably be faster in that case.

-3- Some databases allow nulls in a unique index; some do not. Microsoft allows exactly one null to appear in (adding a second item with a null value would violate the unique index constraint). This scenario is applicable to cases where, e.g., any number of workers might have no Social Security Number, but no SSN may be shared among workers. If the database does not allow nulls in the field, one may have to store an arbitrary value instead. If there's a unique positive integer record number available, one could set the SSN field to be negative that (e.g. for record 1,234 store -1234 in the SSN). One would have to recognize and handle those numbers when viewing the data, but there would be no problem handling multiple SSN-less employees.
GeneralRe: how to avoid data redundancy in insert query? Pin
kssknov16-Dec-07 20:27
kssknov16-Dec-07 20:27 
GeneralProblem regarding port the .dbf files into Sqlserver Pin
Aavesh Agarwal9-Dec-07 17:07
Aavesh Agarwal9-Dec-07 17:07 
Generalcreate a function that check what was the last value last month Pin
midan19-Dec-07 11:43
midan19-Dec-07 11:43 
GeneralRe: create a function that check what was the last value last month Pin
Colin Angus Mackay10-Dec-07 0:05
Colin Angus Mackay10-Dec-07 0:05 
GeneralMoney DataType Pin
DotNetWWW9-Dec-07 6:40
DotNetWWW9-Dec-07 6:40 
GeneralRe: Money DataType Pin
Colin Angus Mackay9-Dec-07 23:57
Colin Angus Mackay9-Dec-07 23:57 
QuestionHow to reset Identity field? Pin
DotNetWWW9-Dec-07 3:57
DotNetWWW9-Dec-07 3:57 
AnswerRe: How to reset Identity field? Pin
Colin Angus Mackay9-Dec-07 5:56
Colin Angus Mackay9-Dec-07 5:56 
QuestionHow to create custome IDENTITY(AutoIncrement) Field? Pin
DotNetWWW9-Dec-07 3:54
DotNetWWW9-Dec-07 3:54 
AnswerRe: How to create custome IDENTITY(AutoIncrement) Field? Pin
Colin Angus Mackay9-Dec-07 5:42
Colin Angus Mackay9-Dec-07 5:42 
AnswerRe: How to create custome IDENTITY(AutoIncrement) Field? Pin
Gamzun9-Dec-07 5:49
Gamzun9-Dec-07 5:49 
QuestionConnect DBF database Pin
AnhTin9-Dec-07 2:49
AnhTin9-Dec-07 2:49 
GeneralProblem port the .dbf files into Sqlserver Pin
Aavesh Agarwal9-Dec-07 17:12
Aavesh Agarwal9-Dec-07 17:12 
GeneralConcatenation in Stored Procedures Pin
CodingYoshi8-Dec-07 9:30
CodingYoshi8-Dec-07 9:30 
GeneralRe: Concatenation in Stored Procedures Pin
pmarfleet8-Dec-07 9:58
pmarfleet8-Dec-07 9:58 
GeneralRe: Concatenation in Stored Procedures Pin
CodingYoshi8-Dec-07 10:53
CodingYoshi8-Dec-07 10:53 
GeneralRe: Concatenation in Stored Procedures Pin
Colin Angus Mackay9-Dec-07 5:52
Colin Angus Mackay9-Dec-07 5:52 

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.