Click here to Skip to main content
15,922,894 members
Home / Discussions / Database
   

Database

 
AnswerRe: Transactions between layers. Pin
Luis C. Lopez25-Oct-06 6:05
Luis C. Lopez25-Oct-06 6:05 
QuestionSearch Security Pin
tmoney10124-Oct-06 2:17
tmoney10124-Oct-06 2:17 
AnswerRe: Search Security Pin
Colin Angus Mackay24-Oct-06 3:38
Colin Angus Mackay24-Oct-06 3:38 
AnswerRe: Search Security Pin
Pete O'Hanlon26-Oct-06 9:05
mvePete O'Hanlon26-Oct-06 9:05 
QuestionOne large table vs. several smaller tables Pin
Joe Smith IX24-Oct-06 0:25
Joe Smith IX24-Oct-06 0:25 
AnswerRe: One large table vs. several smaller tables Pin
Jim Conigliaro24-Oct-06 4:48
Jim Conigliaro24-Oct-06 4:48 
GeneralRe: One large table vs. several smaller tables Pin
Joe Smith IX25-Oct-06 8:49
Joe Smith IX25-Oct-06 8:49 
GeneralRe: One large table vs. several smaller tables Pin
Jim Conigliaro25-Oct-06 9:33
Jim Conigliaro25-Oct-06 9:33 
This isn't a trivial process. Though simple on the surface, there is a lot you need to think about. First, transfering one entry at a time will hurt performance. You would be better off ignoring the queuing concept entirely and just inserting directly to your main table. The general logic you want to follow is this:


Start the transaction
insert from queue into master
delete from queue
commit transaction

syntax for inserting from one table to another is:
INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM TABLE1
Use a lock hint to lock your tables until the transaction is completed, so for example you might have the following code:

BEGIN TRANSACTION<br />
INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM  WITH (TABLOCKX)<br />
DELETE FROM TABLE2<br />
COMMIT



For performance purposes, you may also want to drop the indexes in your main table prior to the insert and then recreate them after the insert.




GeneralRe: One large table vs. several smaller tables Pin
Joe Smith IX26-Oct-06 2:21
Joe Smith IX26-Oct-06 2:21 
GeneralRe: One large table vs. several smaller tables Pin
Jim Conigliaro26-Oct-06 2:33
Jim Conigliaro26-Oct-06 2:33 
QuestionGathering Data and Calculating??? Pin
nit11523-Oct-06 14:50
nit11523-Oct-06 14:50 
AnswerRe: Gathering Data and Calculating??? Pin
Edbert P23-Oct-06 15:01
Edbert P23-Oct-06 15:01 
AnswerRe: Gathering Data and Calculating??? Pin
Rob Graham23-Oct-06 15:03
Rob Graham23-Oct-06 15:03 
GeneralI forgot to mention..... Pin
nit11523-Oct-06 17:01
nit11523-Oct-06 17:01 
AnswerRe: Gathering Data and Calculating??? Pin
Jerry Hammond25-Oct-06 16:50
Jerry Hammond25-Oct-06 16:50 
QuestionLooking for a good Data migration solution Pin
sludgenz23-Oct-06 12:34
sludgenz23-Oct-06 12:34 
AnswerRe: Looking for a good Data migration solution Pin
Edbert P23-Oct-06 15:03
Edbert P23-Oct-06 15:03 
GeneralRe: Looking for a good Data migration solution Pin
sludgenz23-Oct-06 15:27
sludgenz23-Oct-06 15:27 
QuestionOpen XML and DateTime [modified] Pin
GaryWoodfine 23-Oct-06 11:55
professionalGaryWoodfine 23-Oct-06 11:55 
Questionhow to add row to the result query Pin
cellardoor071623-Oct-06 3:46
cellardoor071623-Oct-06 3:46 
AnswerRe: how to add row to the result query Pin
Elina Blank23-Oct-06 3:57
sitebuilderElina Blank23-Oct-06 3:57 
AnswerRe: how to add row to the result query Pin
Eric Dahlvang23-Oct-06 4:04
Eric Dahlvang23-Oct-06 4:04 
GeneralRe: how to add row to the result query Pin
cellardoor071623-Oct-06 4:37
cellardoor071623-Oct-06 4:37 
QuestionSorting In Sqlserver Reports Pin
kjosh23-Oct-06 3:43
kjosh23-Oct-06 3:43 
Questionsearching Pin
m.m._200723-Oct-06 3:33
m.m._200723-Oct-06 3:33 

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.