Solved

Dynamically updating Table from query result in sql server 2005

Posted on 2011-09-20
4
209 Views
Last Modified: 2012-05-12
Hi,
I have an existing table in sql server 2005 database
Id (int, not null)
LoadDate (datetime, null)
Client  (nvarchar,null)
Location (nvarchar, null)
 client tableI want to update this table dynamically using the results of the following query;

Select  client Location
From RawData.NewData

The ID value to be incremented and the LoadDate value to be the date when the query is fired.

any help appreciated..Thanks
0
Comment
Question by:blossompark
  • 2
4 Comments
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 100 total points
Comment Utility
0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 400 total points
Comment Utility
insert into [client table]
(loaddate,client,location)

Select  getdate(),client, Location
From RawData.NewData
where not exists (select client from [client table] as x where x.client=rawdata.newdata.client
 and x.location=rawdata.newdata.location)
0
 

Author Comment

by:blossompark
Comment Utility
Hi angelII,  thanks for the link
Hi Lowfatspread, thanks for that, trying now, will update when complete
0
 

Author Closing Comment

by:blossompark
Comment Utility
Hi AngelII, great info there that i will need to study, thank you...

Hi Lowfatspread, thanks for your input , table has loaded with the data.
I used the following code only for my requirement;
insert into [client table]
(loaddate,client,location)
Select  getdate(),client, Location
From RawData.NewData

I'm assuming
where not exists (select client from [client table] as x where x.client=rawdata.newdata.client
 and x.location=rawdata.newdata.location)

is to prevent duplicate combinations of  client/location from being entered into the client table?

If that is the case that is not a concern in this instance...
as the LoaDate/Client/Location is what needs to be unique
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Analysis of table use 7 27
CREATE DATABASE ENCRYPTION KEY 1 41
Insert with SET how to handle join 6 26
sql calculate averages 18 24
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now