Click here to Skip to main content
15,887,676 members
Home / Discussions / Database
   

Database

 
GeneralRe: emeregency Pin
yousefshokati1-Nov-11 20:23
yousefshokati1-Nov-11 20:23 
GeneralRe: emeregency Pin
Mycroft Holmes1-Nov-11 20:58
professionalMycroft Holmes1-Nov-11 20:58 
GeneralRe: emeregency Pin
yousefshokati1-Nov-11 21:17
yousefshokati1-Nov-11 21:17 
QuestionStored Procedure to Handle CSV Pin
Franklin Smith31-Oct-11 0:32
Franklin Smith31-Oct-11 0:32 
AnswerRe: Stored Procedure to Handle CSV Pin
Mycroft Holmes31-Oct-11 1:11
professionalMycroft Holmes31-Oct-11 1:11 
GeneralRe: Stored Procedure to Handle CSV Pin
Franklin Smith31-Oct-11 2:07
Franklin Smith31-Oct-11 2:07 
GeneralRe: Stored Procedure to Handle CSV Pin
Mycroft Holmes31-Oct-11 11:58
professionalMycroft Holmes31-Oct-11 11:58 
GeneralRe: Stored Procedure to Handle CSV Pin
Franklin Smith31-Oct-11 22:02
Franklin Smith31-Oct-11 22:02 
All the code where I created the temp table and all works like a charm.

The update/insert phase is where I have a problem. It has to do with my limited knowledge of SQL.

Of course during all this I found out the data was being inserted wrong so I have to redo what I've already inserted which gives me a chance to fix the problem. Thank god it isn't live data.

But I finally decided to go with

SET ANSI_WARNINGS  OFF
MERGE PropertyLookupInformation as targetDB
USING TempCsvImport as sourceDB
ON targetDB.RealEstateNumber = sourceDB.RealEstateNumber
WHEN MATCHED
THEN 
UPDATE 
   SET Name = sourceDB.Name
      ,StreetNumber = sourceDB.StreetNumber
      ,StreetName = sourceDB.StreetName
      ,Type = sourceDB.Type
      ,Direction = sourceDB.Direction
      ,Unit = sourceDB.Unit
      ,City = sourceDB.City
      ,ZipCode = sourceDB.ZipCode
      ,LastReviewed = CURRENT_TIMESTAMP
WHEN NOT MATCHED BY TARGET
THEN 
INSERT 
           (PropertyID
           ,RealEstateNumber
           ,Name
           ,StreetNumber
           ,StreetName
           ,Type
           ,Direction
           ,Unit
           ,City
           ,ZipCode
           ,LastReviewed)
     VALUES
           ( NEWID()
           ,sourceDB.RealEstateNumber
           ,sourceDB.Name
           ,sourceDB.StreetNumber
           ,sourceDB.StreetName
           ,sourceDB.Type
           ,sourceDB.Direction
           ,sourceDB.Unit
           ,sourceDB.City
           ,sourceDB.ZipCode
           ,CURRENT_TIMESTAMP)
           ;


The only thing I'm not sure of doing it this way is performance issues.

Now just to get it put into a stored proc and we are set and ready to go.
GeneralRe: Stored Procedure to Handle CSV Pin
Mycroft Holmes31-Oct-11 22:52
professionalMycroft Holmes31-Oct-11 22:52 
AnswerRe: Stored Procedure to Handle CSV Pin
PIEBALDconsult1-Nov-11 3:00
mvePIEBALDconsult1-Nov-11 3:00 
Questionmysql client mobile app Pin
Jassim Rahma30-Oct-11 4:58
Jassim Rahma30-Oct-11 4:58 
QuestionFill gaps in rates data with previous working day rates. Pin
Dev S30-Oct-11 3:00
Dev S30-Oct-11 3:00 
AnswerRe: Fill gaps in rates data with previous working day rates. Pin
Mycroft Holmes30-Oct-11 12:52
professionalMycroft Holmes30-Oct-11 12:52 
QuestionGrant a role to another role Pin
Danzy8329-Oct-11 12:31
Danzy8329-Oct-11 12:31 
QuestionJust installed SQL Server 2008 R2 - Where is the app to create/open/add/update/delete DB file? Pin
swampwiz28-Oct-11 0:40
swampwiz28-Oct-11 0:40 
AnswerRe: Just installed SQL Server 2008 R2 - Where is the app to create/open/add/update/delete DB file? Pin
Geoff Williams28-Oct-11 1:29
Geoff Williams28-Oct-11 1:29 
AnswerRe: Just installed SQL Server 2008 R2 - Where is the app to create/open/add/update/delete DB file? Pin
phil.o28-Oct-11 2:25
professionalphil.o28-Oct-11 2:25 
QuestionNeed help with update SQL with subquery Pin
Hypermommy26-Oct-11 3:14
Hypermommy26-Oct-11 3:14 
AnswerRe: Need help with update SQL with subquery Pin
Corporal Agarn26-Oct-11 3:46
professionalCorporal Agarn26-Oct-11 3:46 
AnswerRe: Need help with update SQL with subquery Pin
Hypermommy26-Oct-11 6:03
Hypermommy26-Oct-11 6:03 
QuestionSELECT ... GROUP BY Error Pin
MikeDhaan26-Oct-11 1:07
MikeDhaan26-Oct-11 1:07 
AnswerRe: SELECT ... GROUP BY Error Pin
Simon_Whale26-Oct-11 1:13
Simon_Whale26-Oct-11 1:13 
GeneralRe: SELECT ... GROUP BY Error Pin
MikeDhaan26-Oct-11 1:59
MikeDhaan26-Oct-11 1:59 
GeneralRe: SELECT ... GROUP BY Error Pin
Jörgen Andersson26-Oct-11 2:37
professionalJörgen Andersson26-Oct-11 2:37 
GeneralRe: SELECT ... GROUP BY Error Pin
MikeDhaan26-Oct-11 5:14
MikeDhaan26-Oct-11 5:14 

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.