如何将数据从一个表转移到另一个表? [英] how to transfer data from one table to another ?

查看:87
本文介绍了如何将数据从一个表转移到另一个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表

Tbl_Future第一名

id,Product,Datetime

Tbl_Live排名第二

id,产品

Tbl_Future中有一些带有时间的产品记录

现在我想在服务器时间达到产品时间时传输该数据,
然后在那个时候我想从Tbl_Future转移到Tbl_Live .....

----

jab jis产品ka时间服务器时间jitna ho选项卡数据Tbl_Future mese Tbl_Live me transfer ho .....

请帮助我.....

i have two tables

1st for Tbl_Future
with
id, Product , Datetime

2nd for Tbl_Live
with
id , Product

there some product records with time in Tbl_Future

now i want to transfer that data when server time reaches to product time,
then at that time for that i want to transfer from Tbl_Future to Tbl_Live.....

----

jab jis product ka time server time jitna ho tab data Tbl_Future mese Tbl_Live me transfer ho.....

please help me.....

推荐答案

而不是两个表,为什么不保留一个表并使用类似
的查询 SELECT * FROM tblData WHERE DateTime < getdate().除非您有一个非常具体的理由为什么要在系统中拥有冗余数据,否则我将采用这种方式.
Instead of two tables, why not just keep the one table and use a query something like
SELECT * FROM tblData WHERE DateTime < getdate(). Unless you have a very specific reason why to have redundant data in the system, that is the way I would go.


理想情况下,我会采用上述解决方案,但在某些情况下,您会这样做想要一个冗余的数据集.在这种情况下,

tbl_future中不同产品中的日期之间有什么区别?
例如,考虑tbl_future中的以下数据行:
Ideally, I would go for the above solution but in some instances you would want a redundant data set. In this scenario,

What is the difference between dates within different products in tbl_future ?
For example, consider the below data rows in tbl_future:
1000 Product1 2011-01-01 12:00:00.000
1001 Product2 2011-01-01 12:00:00.000
1002 Product3 2011-01-01 13:00:00.000
1003 Product4 2011-01-01 13:00:00.000




我之所以这样问,是因为必须根据上述数据的正确分析来安排以下解决方案

举例来说,这批产品的日期时间差为0.5小时

然后使用以下sql语句安排一个作业,该作业每0.5小时或每5分钟运行一次,具体取决于数据量




I am asking this because the below solution will have to be scheduled on the correct analysis of the above data

Say for example, the batch of products have datetime differences by 0.5 hours

Then schedule a job which runs every 0.5 hours or every 5 minutes depending on the volume of the data with the following sql statement

insert into tbl_live
    select id, product from tbl_future where upTime = getdate()
-- here upTime is the datetime column in tbl_future


这篇关于如何将数据从一个表转移到另一个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆