?
Solved

Dynamically updating Table from query result in sql server 2005

Posted on 2011-09-20
4
Medium Priority
?
216 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 400 total points
ID: 36566041
0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 1600 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

770 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