Solved

Dynamically updating Table from query result in sql server 2005

Posted on 2011-09-20
4
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Assisted Solution

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

Accepted Solution

by:
Lowfatspread earned 400 total points
ID: 36566109
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
ID: 36566165
Hi angelII,  thanks for the link
Hi Lowfatspread, thanks for that, trying now, will update when complete
0
 

Author Closing Comment

by:blossompark
ID: 36566251
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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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