Click here to Skip to main content
15,919,774 members
Home / Discussions / Database
   

Database

 
GeneralRe: backing up/moving mssql databases Pin
djkno36-Oct-03 8:11
djkno36-Oct-03 8:11 
GeneralRe: backing up/moving mssql databases Pin
Mike Dimmick6-Oct-03 23:20
Mike Dimmick6-Oct-03 23:20 
GeneralRe: backing up/moving mssql databases Pin
djkno37-Oct-03 4:18
djkno37-Oct-03 4:18 
GeneralRe: backing up/moving mssql databases Pin
Mike Dimmick7-Oct-03 22:39
Mike Dimmick7-Oct-03 22:39 
GeneralSqlDataAdapter.Update sometimes does not update Pin
james-cxx2-Oct-03 10:55
james-cxx2-Oct-03 10:55 
GeneralRe: SqlDataAdapter.Update sometimes does not update Pin
james-cxx14-Oct-03 18:18
james-cxx14-Oct-03 18:18 
GeneralLogic Pin
Anonymous2-Oct-03 3:58
Anonymous2-Oct-03 3:58 
GeneralRe: Logic Pin
Mike Dimmick2-Oct-03 12:14
Mike Dimmick2-Oct-03 12:14 
Assumption: you mean that you want to select the rows which have the lowest date, whichever table they come from.

On this assumption, I think doing a UNION of the tables is probably about right.
SELECT [ID], MIN( Dateentered ) AS MinDate
FROM Table1 UNION ALL Table2
GROUP BY [ID]
If you actually want to insert rows or update rows in table 2, that's a bit trickier, and would have to be done in two stages:
-- Insert any rows into Table2 that are in Table1
-- but not in Table2
INSERT INTO Table2
SELECT T1.[ID], T1.Dateentered
FROM Table1 T1
LEFT JOIN Table2 T2 ON T1.[ID] = T2.[ID]
WHERE T2.[ID] IS NULL
 
-- Set Table2's entries to the date in Table1,
-- if table1's are earlier
UPDATE Table2
SET Dateentered = T1.Dateentered
FROM Table1 T1
INNER JOIN Table2 T2 ON T1.[ID] = T2.[ID]
WHERE
   [ID] = T1.[ID] AND
   T1.Dateentered < T2.Dateentered

GeneralWeird problem while inserting a record Pin
2sky1-Oct-03 23:53
2sky1-Oct-03 23:53 
GeneralRe: Weird problem while inserting a record Pin
Mike Dimmick2-Oct-03 3:26
Mike Dimmick2-Oct-03 3:26 
GeneralRe: Weird problem while inserting a record Pin
2sky2-Oct-03 3:35
2sky2-Oct-03 3:35 
Generalerror deleting record in datagrid Pin
Giovanni Bejarasco1-Oct-03 23:09
Giovanni Bejarasco1-Oct-03 23:09 
GeneralRe: error deleting record in datagrid Pin
Mike Dimmick2-Oct-03 12:18
Mike Dimmick2-Oct-03 12:18 
GeneralRe: error deleting record in datagrid Pin
Giovanni Bejarasco2-Oct-03 20:07
Giovanni Bejarasco2-Oct-03 20:07 
GeneralRe: error deleting record in datagrid Pin
Mike Dimmick2-Oct-03 22:30
Mike Dimmick2-Oct-03 22:30 
GeneralRe: error deleting record in datagrid Pin
Giovanni Bejarasco3-Oct-03 1:41
Giovanni Bejarasco3-Oct-03 1:41 
GeneralRe: error deleting record in datagrid Pin
Ian Darling3-Oct-03 22:16
Ian Darling3-Oct-03 22:16 
GeneralDatabases concurrecny issues Pin
Jahangir Jamshed1-Oct-03 19:26
sussJahangir Jamshed1-Oct-03 19:26 
GeneralRe: Databases concurrecny issues Pin
Andy Harman1-Oct-03 22:51
Andy Harman1-Oct-03 22:51 
GeneralRe: Databases concurrecny issues Pin
Mike Dimmick2-Oct-03 3:37
Mike Dimmick2-Oct-03 3:37 
GeneralRe: Databases concurrecny issues Pin
SimonS2-Oct-03 22:46
SimonS2-Oct-03 22:46 
GeneralDataRowState Problems Pin
Wjousts1-Oct-03 11:33
Wjousts1-Oct-03 11:33 
GeneralRe: DataRowState Problems Pin
Giovanni Bejarasco3-Oct-03 1:46
Giovanni Bejarasco3-Oct-03 1:46 
QuestionIndexing Problem??? Pin
Jason Weibel1-Oct-03 8:32
Jason Weibel1-Oct-03 8:32 
AnswerRe: Indexing Problem??? Pin
andyharman1-Oct-03 12:01
professionalandyharman1-Oct-03 12: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.