Wednesday, March 21, 2012

From one server to another

Bear in mind that I am just a beginner and ingorance is bliss!

Two questions

1. Could someone tell me the most efficient (and easiest) way to move summurize and move data from one db on server A to another db on serverB. This process needs to run on an hourly basis.

If they were on the same server I would create a job under Management and use this code.

INSERT INTO tblNewTable
SELECT SUM(thiscolumn), SUM(thatcolumn), SUM(ETC)
FROM tblOld
WHERE columnDateTime > (SELECT MAX(columnDateTime) FROM tblNewTable)
GROUP BY DATEPART(hh, columnDate), Line, Shift

My problem is I THINK that you have to script the connection between the two severs and I dont know how to do this.

2. In tblNewTable, the data is used to report machine efficency for each line and shift. The problem is that the 3rd shift begins at 11PM, but its production is applied to the following day. I have used

WHERE columnDateTime >= DATEADD(hh, -1, StartDate) AND columnDateTime <= DATEADD(hh, -1, EndDate)

and leave off the GROUP BY columnDateTime to get the shift's data together.

Is it possible for 11 to 12 PM to be brought in as the following days date?

Thanks,
LeeQ1 [Do I have to script] the connection between the two severs? and I how [do I] do this.
A1 You might want to use linked servers (you could use osql if you really want to script a connection).

Q2 Is it possible for 11 to 12 PM to be brought in as the following days date?
A2 Yes, but you will need to code the logic to do so. (case and / or if statements, etc.)

No comments:

Post a Comment