Click here to Skip to main content
16,006,065 members
Home / Discussions / Database
   

Database

 
GeneralRe: Error in connecting remotely to database Pin
Talal Sultan9-Aug-07 23:59
Talal Sultan9-Aug-07 23:59 
GeneralRe: Error in connecting remotely to database Pin
IamAmit10-Aug-07 0:04
IamAmit10-Aug-07 0:04 
GeneralRe: Error in connecting remotely to database Pin
Talal Sultan10-Aug-07 0:11
Talal Sultan10-Aug-07 0:11 
GeneralRe: Error in connecting remotely to database Pin
IamAmit10-Aug-07 0:22
IamAmit10-Aug-07 0:22 
GeneralRe: Error in connecting remotely to database Pin
sam#10-Aug-07 1:35
sam#10-Aug-07 1:35 
GeneralRe: Error in connecting remotely to database Pin
Talal Sultan10-Aug-07 1:56
Talal Sultan10-Aug-07 1:56 
QuestionBulk insert Pin
John.L.Ponratnam9-Aug-07 3:03
John.L.Ponratnam9-Aug-07 3:03 
AnswerRe: Bulk insert Pin
andyharman9-Aug-07 4:41
professionalandyharman9-Aug-07 4:41 
Hi John

In this case, I normally do a bulk insert into a temporary table then run the following to update existing records:
update MMT set
    Value1 = T1.Value1,
    Value2 = T1.Value2,
    LastUpdateDate = GetDate()
  from MyMainTable MMT
  inner join #MyBulkInsertTable T1
  on T1.Id = MyMainTable.Id
  where T1.Value1 <> MMT.Value1 or T1.Value2 <> MMT.Value2
The where-clause ensures that you only update records that have changed. If the Value1 and Value2 columns can be null then I normally use the IsNull function to force a value in the comparison.

And the following to insert new records:
insert into MyMainTable
  select T1.Id, T1.Value1, T1.Value2, GetDate() as InsertDate,
      GetDate() as LastUpdateDate
  from #MyBulkInsertTable T1
  left outer join MyMainTable MMT
    on MMT.Id = T1.Id
  where MMT.Id is null
This uses an outer-join to identify rows that have not yet been loaded. The "InsertDate" and "LastUpdateDate" columns provide a primative audit trail that can be useful when things go wrong.

A similar technique can be used for deleting records from MyMainTable.

Hope that helps.

Regards
Andy

If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".

QuestionServer Error i need to solve this error Pin
Rami Said Abd Alhalim9-Aug-07 2:35
Rami Said Abd Alhalim9-Aug-07 2:35 
AnswerRe: Server Error i need to solve this error Pin
Blue_Boy9-Aug-07 2:46
Blue_Boy9-Aug-07 2:46 
GeneralRe: Server Error i need to solve this error Pin
Rami Said Abd Alhalim9-Aug-07 2:50
Rami Said Abd Alhalim9-Aug-07 2:50 
AnswerRe: Server Error i need to solve this error Pin
Talal Sultan9-Aug-07 3:51
Talal Sultan9-Aug-07 3:51 
GeneralRe: Server Error i need to solve this error Pin
Rami Said Abd Alhalim10-Aug-07 19:38
Rami Said Abd Alhalim10-Aug-07 19:38 
QuestionServer: Msg 128, Level 15, State 1, Line 3 Pin
IamAmit9-Aug-07 2:00
IamAmit9-Aug-07 2:00 
AnswerRe: Server: Msg 128, Level 15, State 1, Line 3 Pin
ChandraRam9-Aug-07 2:02
ChandraRam9-Aug-07 2:02 
AnswerRe: Server: Msg 128, Level 15, State 1, Line 3 Pin
Mike Dimmick9-Aug-07 10:35
Mike Dimmick9-Aug-07 10:35 
QuestionHow to run a .sql file in SQL Server 2005 Express Edition. Pin
Paramhans Dubey9-Aug-07 0:55
professionalParamhans Dubey9-Aug-07 0:55 
AnswerRe: How to run a .sql file in SQL Server 2005 Express Edition. Pin
originSH9-Aug-07 1:23
originSH9-Aug-07 1:23 
AnswerRe: How to run a .sql file in SQL Server 2005 Express Edition. Pin
Craster9-Aug-07 1:42
Craster9-Aug-07 1:42 
AnswerRe: How to run a .sql file in SQL Server 2005 Express Edition. Pin
Pete O'Hanlon9-Aug-07 1:45
mvePete O'Hanlon9-Aug-07 1:45 
Questionprint report without preview Pin
Rupesh Kumar Swami8-Aug-07 22:28
Rupesh Kumar Swami8-Aug-07 22:28 
AnswerRe: print report without preview Pin
Pete O'Hanlon9-Aug-07 1:41
mvePete O'Hanlon9-Aug-07 1:41 
GeneralRe: print report without preview Pin
Rupesh Kumar Swami9-Aug-07 3:16
Rupesh Kumar Swami9-Aug-07 3:16 
GeneralRe: print report without preview Pin
Pete O'Hanlon9-Aug-07 3:50
mvePete O'Hanlon9-Aug-07 3:50 
GeneralRe: print report without preview Pin
Dave Kreskowiak9-Aug-07 10:07
mveDave Kreskowiak9-Aug-07 10:07 

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.