SQL 2012 :: Replication Fails - Cannot Truncate Table
Apr 24, 2015
We have an issue where we are trying to replicate a DB using SQL replication, the Replication Monitor reports an error:
Cannot TRUNCATE TABLE 'dbo.xxx' because it is being referenced by object 'View_xxx'.
Although I am the DBA, I do not have an inside knowledge of this particular DB.
View 2 Replies
Feb 9, 2015
SQL 2012 Ent SP2
Database is in simple recovery mode, and published with transaction replication push subscription, just one subscriber but the database is huge. I don't want to overwrite the schema at the subscriber either.
I had to run an alter database command on a published database, it created so many logs that an extra drive had to be added along with an extra log file to accommodate all the logs.
The problem I have is I'd like to know clear the file of logs so I can drop the temporary log file, and give the drive back, but I cannot.
I have tried dbcc shrinkfile with the emptyfile option but it never clears, I have also tried it with notruncate and truncateonly options (mainly out of desperation).
I do not need to worry about point in time restore as a full backup is taken before and after the operation. After which the database will be put back into Full recovery mode.
I have looked at log_reuse_wait_desc and the file says 'Replication', so I am now thinking the file cannot empty because replication is keeping one of the VLFs active. I tried dropping and recreating the subscription hoping it might free something up and I could get somewhere, but it made no difference.
Do I have to remove replication completely to get round this? Surely not.
I have also tried putting the database back into full recovery mode, doing a full DB backup, and a transaction log backup, but its made no difference, which is also what makes me think a portion of the log is still active because of replication, and perhaps the transactions have not gone through to the subscriber, which raises another question, why not?
I have not tried restarting SQL server, as I'd like to know a way out of this without having to do that, plus I do not think it would make any difference anyway.
View 1 Replies
View Related
Dec 7, 2006
Hey,
I have SQL Server 2000 DB that was converted via DTS from Acccess 97. Replication fails for any table with a single hypen in the table name. If I copy one of these tables to a name using an underscore rather than a hyphen, then it replicates successfully.
Below are errror messags from agent with -Outputverboselevel set to 2. I have also seen 'Agent error code 20082', in which case the replication command is incomplete.
Any ideas?
Thanks,
Bill Coulter
[12/7/2006 1:22:40 PM]172.23.150.51.engdata: {CALL sp_MSupd_br1-16 (NULL,?,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,?,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,?,0x0200020000)}
Parameterized values for above command(s): {{N'00000000001010000100', N'000000000000000000', N'730535L1205C'}}
Agent message code 20046. Syntax error or access violation
[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_distribution_history(57, 6, ?, ?, 27, 27, 2.32, 0x01, 1, ?, 1, 0x00, 0x01)}
Adding alert to msdb..sysreplicationalerts: ErrorId = 18,
Transaction Seqno = 0000108b000028f2000400000000, Command ID = 1
Message: Replication-Replication Distribution Subsystem: agent OUSBID02-engdata-172.23.150.51-57 failed. Syntax error or access violation[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_repl_alert(3, 57, 18, 14151, ?, 1, N'OUSBID02', N'engdata', N'172.23.150.51', N'engdata', ?)}
ErrorId = 18, SourceTypeId = 1
ErrorCode = ''
ErrorText = '{CALL sp_MSupd_br1-16 (NULL,N'00000000001010000100',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'000000000000000000',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'730535L1205C',0x0200020000)} '
[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_repl_error(18, 0, 1, ?, N'', ?)}
Category:COMMAND
Source: Failed Command
Number:
Message: {CALL sp_MSupd_br1-16 (NULL,N'00000000001010000100',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'000000000000000000',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'730535L1205C',0x0200020000)}
ErrorId = 18, SourceTypeId = 4
ErrorCode = '37000'
ErrorText = 'Syntax error or access violation'
[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_repl_error(18, 0, 4, ?, N'37000', ?)}
Category:ODBC
Source: xxx.xx.xx.xx
Number: 37000
Message: Syntax error or access violation
View 8 Replies
View Related
Jun 30, 2014
I was just looking at an SSIS package someone else set up and I went into one of the execute SQL tasks and it is calling a stored procedure to truncate a table. There are a lot of places that tables are truncated within this SSIS package. But each one the 'database', 'owner', and 'table' name are hard coded.
Like this: exec dbo.uspTruncateTable 'dbname', 'dbo', 'tblname'
Of course there are different names, just changed for an example.
Here is the code in the Stored Procedure.
CREATE procedure [dbo].[uspTruncateTable]
@nDatabase varchar(255),
@nOwner varchar(255),
@ntable varchar(255)
as
declare @sqlString nvarchar(max)
set @sqlString = 'Truncate Table ' + @nDatabase + '.' + @nOwner + '.' + @ntable
exec (@sqlString)
This just seems like an unneeded step, just code the 'truncate table dbname.dbo.tblname'.
View 5 Replies
View Related
Feb 10, 2005
Hi,
(From Bol)
"You Cannot Use Truncate Table On A Table Referenced By A Foreign Key
Constraint;"
1) States
Statecode TinyintPrimary Key
Statename Varchar(25)
2) Rivers
RivercodeSmallint Primary Key
RivernameVarchar(40)
3) Riverinstates
StatecodeTinyint,
RivercodeSmallint,
Constraint Pkriverinstates Primary Key(Statecode,Rivercode),
Constraint Fkriverinstates
Foreign Key (Statecode) References States(Statecode),
Foreign Key (Rivercode) References Rivers(Rivercode)
after removing all rows from RiverInStates Table using TRUNCATE and the command completed successfully.
when i tried to remove all rows from Rivers table , i got the following error.
"Server: Msg 4712, Level 16, State 1, Line 76
Cannot truncate table 'rivers' because it is being referenced by a FOREIGN
KEY constraint."
i thought the error may be due to the "Fkriverinstates" FOREIGN KEY CONSTRAINT. so i DROPped the constraint with
ALTER TABLE RiverinStates DROP CONSTRAINT Fkriverinstates
even after DROPping the constraint, im getting the same error
can any one point out where the problem is?
thanks in advance
View 1 Replies
View Related