Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update from view to other table

Author  Topic 

Zul
Starting Member

17 Posts

Posted - 2009-05-29 : 00:32:04
i have 2 database
1 db master, 2 db client
in db master i have alots of table, and make view in the db master to make smaller. exampel

view

f1
f2
f3
f4
f5.

i db client i make 1 table (table1)that in this table the field have same data with the view on db master.

i have all ready migration data view from db master to table in db client (table 1)
my question is how can i make script update data in db clien if data in view master has change

regrads

Zulkifli

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-29 : 14:18:13
do you want this change to be applied immediately or periodically? ie after regular intervals?
Go to Top of Page

Zul
Starting Member

17 Posts

Posted - 2009-06-01 : 23:18:11
quote:
Originally posted by visakh16

do you want this change to be applied immediately or periodically? ie after regular intervals?



i want to update this change every midnight.
can you tell me the script to update this database?
as i know that to update the script every midnight is using jobs in sql, can you too show me articel or the step by step to make a jobs?

thanks

Zul
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-01 : 23:35:05
you can create a stored procedure to perform the update and then schedule it using SQL Agent to run at midnight.

see here http://msdn.microsoft.com/en-us/library/ms187061(SQL.90).aspx on SQL Agent.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Zul
Starting Member

17 Posts

Posted - 2009-06-02 : 02:49:04
quote:
Originally posted by khtan

you can create a stored procedure to perform the update and then schedule it using SQL Agent to run at midnight.

see here http://msdn.microsoft.com/en-us/library/ms187061(SQL.90).aspx on SQL Agent.


KH
[spoiler]Time is always against us[/spoiler]





can you show me the query??
because i'm newbie in SQL
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2009-06-02 : 09:31:54
Can it be a total refresh of the client table with the data from the master db or do you retain any changes made by the client on the client db?

Edit: Also, post your DDL, for both master and client, and some examples of the data for the master and the expected results on the client.

Terry

-- Procrastinate now!
Go to Top of Page

Zul
Starting Member

17 Posts

Posted - 2009-06-02 : 22:58:03
yes it totaly refresh of the client with the db master. if db master has change then db client change same with db master. but db client can't change selve without db master.

SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, im_is_breached,
im_full_name, userAnalis, status, nama, Analyst
FROM dbo.VIncident
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, ca_is_breached,
ca_full_name, userAnalis, status, nama, Analyst
FROM dbo.VCall
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, cm_is_breached,
cm_full_name, userAnalis, status, nama, Analyst
FROM dbo.VChange
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, pr_is_breached,
pm_full_name, userAnalis, status, nama, Analyst
FROM dbo.VProblem
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, cm_is_breached,
cm_full_name, userAnalis, status, nama, Analyst
FROM dbo.VRelease

this is query to make view in DB Master


insert into master.dbo.process (ticket_guid,ticket_id,raise_date,last_update,closure_date,ticket_type,description,title,raise_user_name,priority,is_breach,maincategory,tipeuser,status)
select * from client.dbo.VAllprocess

this is query to migration from db master to db client
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2009-06-03 : 08:14:33
quote:
Originally posted by Zul

yes it totaly refresh of the client with the db master. if db master has change then db client change same with db master. but db client can't change selve without db master.

SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, im_is_breached,
im_full_name, userAnalis, status, nama, Analyst
FROM dbo.VIncident
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, ca_is_breached,
ca_full_name, userAnalis, status, nama, Analyst
FROM dbo.VCall
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, cm_is_breached,
cm_full_name, userAnalis, status, nama, Analyst
FROM dbo.VChange
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, pr_is_breached,
pm_full_name, userAnalis, status, nama, Analyst
FROM dbo.VProblem
UNION ALL
SELECT pm_guid, pm_id, pm_raise_date, pm_last_update, closureDate, usr_reference, pm_description, pm_title, tps_name, lc_title, cm_is_breached,
cm_full_name, userAnalis, status, nama, Analyst
FROM dbo.VRelease

this is query to make view in DB Master


insert into master.dbo.process (ticket_guid,ticket_id,raise_date,last_update,closure_date,ticket_type,description,title,raise_user_name,priority,is_breach,maincategory,tipeuser,status)
select * from client.dbo.VAllprocess

this is query to migration from db master to db client




OK. Your insert statement is going into master not client. Which way is it truly going? And why are you putting user tables in the master database? Definitely not a best practices approach!

Terry

-- Procrastinate now!
Go to Top of Page
   

- Advertisement -