blossompark
asked on
Dynamically updating Table from query result in sql server 2005
Hi,
I have an existing table in sql server 2005 database
Id (int, not null)
LoadDate (datetime, null)
Client (nvarchar,null)
Location (nvarchar, null)
I 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
I have an existing table in sql server 2005 database
Id (int, not null)
LoadDate (datetime, null)
Client (nvarchar,null)
Location (nvarchar, null)
I 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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.c lient
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
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.c
and x.location=rawdata.newdata
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
ASKER
Hi Lowfatspread, thanks for that, trying now, will update when complete