January 7, 2017 at 2:18 pm
Hi,
We have a SQL Job that truncate tables in one database then insert into the tables from different database. Some times we are missing some data with in the destination tables even though data is exists in the source tables.
Do we need to put
TRUNCATE TABLE TestDB2.DBA.Test1
Truncate Table TestDB2.DBA.Test2
INSERT TestDB2.DBA.Test1
(col1,
col2,
col3,
col4
)
SELECT col1, col2, col3,col4
FROM [TestDB1].[dbo].[Test1]
INSERT TestDB2.DBA.Test2
(col1,
col2,
col3
)
SELECT col1, col2, col3
FROM [TestDB1].[dbo].[Test2]
January 7, 2017 at 3:03 pm
Do you have a question?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
January 7, 2017 at 4:08 pm
ramana3327 (1/7/2017)
Hi,We have a SQL Job that truncate tables in one database then insert into the tables from different database. Some times we are missing some data with in the destination tables even though data is exists in the source tables.
Do we need to put
TRUNCATE TABLE TestDB2.DBA.Test1
Truncate Table TestDB2.DBA.Test2
INSERT TestDB2.DBA.Test1
(col1,
col2,
col3,
col4
)
SELECT col1, col2, col3,col4
FROM [TestDB1].[dbo].[Test1]
INSERT TestDB2.DBA.Test2
(col1,
col2,
col3
)
SELECT col1, col2, col3
FROM [TestDB1].[dbo].[Test2]
It appears that the data in these two tables is expendable. Consider setting it all up for "Minimal Logging" so that it's faster and less resource intensive. Google is your friend on the "Minimal Logging" thing and it's very well worth learning about.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 9, 2017 at 6:46 am
We are using the database in simple recovery. I believe simple recovery model is also minimally logged.
February 9, 2017 at 7:40 am
ramana3327 - Thursday, February 9, 2017 6:46 AMWe are using the database in simple recovery. I believe simple recovery model is also minimally logged.
They are not the same thing. Read this article to improve your understanding of minimal logging, as your Googling skills appear to have deserted you.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
February 9, 2017 at 9:22 am
ramana3327 - Thursday, February 9, 2017 6:46 AMWe are using the database in simple recovery. I believe simple recovery model is also minimally logged.
Nope. That's not all you have to do. Please see the link that Phil pointed you to. And, to be sure, the DB doesn't need to be in the SIMPLE Recovery Model to do minimal logging. It can also be in the BULK Logged Recovery Model and requires the same attention to detail that Minimal Logging requires in the SIMPLE Recovery Model.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply