Click here to Skip to main content
15,900,325 members
Home / Discussions / Database
   

Database

 
GeneralRe: Avoining duplicates while joining tables Pin
Ashfield21-Jul-09 4:43
Ashfield21-Jul-09 4:43 
QuestionApproach for CRUD transactions of a dynamic form Pin
Member 288307020-Jul-09 23:04
Member 288307020-Jul-09 23:04 
QuestionInsert Query Pin
sachees12320-Jul-09 22:07
sachees12320-Jul-09 22:07 
AnswerRe: Insert Query Pin
DoctorMick21-Jul-09 0:23
DoctorMick21-Jul-09 0:23 
AnswerRe: Insert Query Pin
Ashfield21-Jul-09 2:01
Ashfield21-Jul-09 2:01 
AnswerRe: Insert Query Pin
PIEBALDconsult21-Jul-09 5:18
mvePIEBALDconsult21-Jul-09 5:18 
QuestionSQL server 2005 Reporting Services Pin
Aman786Singh20-Jul-09 21:10
Aman786Singh20-Jul-09 21:10 
QuestionUPSERT implementation Pin
PIEBALDconsult20-Jul-09 10:36
mvePIEBALDconsult20-Jul-09 10:36 
I was looking for an implementation of "UPSERT" that I could execute with one call to ExecuteNonQuery against SQL Server 2000*. Not being familiar with EXISTS and HAVING, but being very familiar with JOIN, I wrote the following:

INSERT INTO MyTable ( Id )
SELECT T1.Id
FROM ( SELECT Id = @Id ) T1
LEFT OUTER JOIN MyTable T2
ON T1.Id = T2.Id
WHERE T2.Id IS NULL
;
UPDATE MyTable
SET Field1 = @Field1
    ...
WHERE Id = @Id


It works, and, for the particular task, I'm not concerned about scalability**, but I thought I'd post here to get feedback on whether or not there are commonly-used implementations which are held to be superior.


* I try to be database agnostic, so I prefer solutions that don't rely on a particular database system.

** This particular table has only the Id and one other field, and there will be fewer than 1000 records. However, the general case should be considered.
AnswerRe: UPSERT implementation Pin
--CELKO--20-Jul-09 14:28
--CELKO--20-Jul-09 14:28 
GeneralRe: UPSERT implementation Pin
David Skelly21-Jul-09 2:19
David Skelly21-Jul-09 2:19 
GeneralRe: UPSERT implementation Pin
PIEBALDconsult21-Jul-09 5:07
mvePIEBALDconsult21-Jul-09 5:07 
QuestionIs there an SQL Formatter based on Celko's SQL PROGRAMMING STYLE? Pin
--CELKO--20-Jul-09 7:27
--CELKO--20-Jul-09 7:27 
AnswerRe: Is there an SQL Formatter based on Celko's SQL PROGRAMMING STYLE? Pin
PIEBALDconsult20-Jul-09 10:38
mvePIEBALDconsult20-Jul-09 10:38 
GeneralRe: Is there an SQL Formatter based on Celko's SQL PROGRAMMING STYLE? Pin
--CELKO--20-Jul-09 14:26
--CELKO--20-Jul-09 14:26 
QuestionTemporary Table Pin
abcurl20-Jul-09 5:31
abcurl20-Jul-09 5:31 
AnswerRe: Temporary Table Pin
David Mujica20-Jul-09 5:54
David Mujica20-Jul-09 5:54 
GeneralRe: Temporary Table Pin
abcurl20-Jul-09 7:49
abcurl20-Jul-09 7:49 
GeneralRe: Temporary Table Pin
David Mujica20-Jul-09 8:19
David Mujica20-Jul-09 8:19 
GeneralRe: Temporary Table Pin
Ashfield20-Jul-09 20:58
Ashfield20-Jul-09 20:58 
GeneralRe: Temporary Table Pin
Robin_Roy21-Jul-09 18:08
Robin_Roy21-Jul-09 18:08 
QuestionHow to call VBA function on command event in access 2007? Pin
monika_vasvani20-Jul-09 3:34
monika_vasvani20-Jul-09 3:34 
AnswerRe: How to call VBA function on command event in access 2007? Pin
riced20-Jul-09 3:53
riced20-Jul-09 3:53 
QuestionImport XML to SQL Pin
Vimalsoft(Pty) Ltd20-Jul-09 1:57
professionalVimalsoft(Pty) Ltd20-Jul-09 1:57 
AnswerRe: Import XML to SQL Pin
Ashfield20-Jul-09 2:19
Ashfield20-Jul-09 2:19 
GeneralRe: Import XML to SQL Pin
Vimalsoft(Pty) Ltd20-Jul-09 3:01
professionalVimalsoft(Pty) Ltd20-Jul-09 3:01 

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.