I am having problems setting up change data capture on a SQL Server 2012 instance. Whenever I attempt to enable CDC on a table I get the following error:
Msg 22832, Level 16, State 1, Procedure sp_cdc_enable_table_internal,
Line 623
Could not update the metadata that indicates table
[dbo].[TableName] is enabled for Change Data Capture.
The failure
occurred when executing the command '[sys].[sp_cdc_add_job] #job_type
= N'capture''.
The error returned was 22836: 'Could not update the metadata for database [database name] to indicate that a Change Data Capture
job has been added. The failure occurred when executing the command
'sp_add_jobstep_internal'.
The error returned was 14234: 'The
specified '#server' is invalid (valid values are returned by
sp_helpserver).'. Use the action and error to determine the cause of
the failure and resubmit the request.'. Use the action and error to
determine the cause of the failure and resubmit the request.
The name of the server has not changed, I tried the sp_dropserver / sp_addserver solution and receive the following error:
Msg 15015, Level 16, State 1, Procedure sp_dropserver, Line 42
The server 'ServerName' does not exist. Use sp_helpserver to show
available servers.
Msg 15028, Level 16, State 1, Procedure sp_addserver, Line 74
The server 'ServerName' already exists.
As I've stated, I'm trying to set up CDC and not replication. The version of SQL Server is: 11.0.5058.0 (SQL Server 2012 SP2)
I've looked at Error while enabling CDC on table level and tried that solution.
I've also tried:
exec sys.sp_cdc_add_job #job_type = N'capture'
I receive the following error:
Msg 22836, Level 16, State 1, Procedure sp_cdc_add_job_internal, Line 282
Could not update the metadata for database [DatabaseName] to indicate
that a Change Data Capture job has been added. The failure occurred
when executing the command 'sp_add_jobstep_internal'.
The error returned was 14234: 'The specified '#server' is invalid (valid values are returned by sp_helpserver).'. Use the action and error to
determine the cause of the failure and resubmit the request.
Any help would be greatly appreciated.
As listed here, check the names match
SELECT srvname AS OldName FROM master.dbo.sysservers
SELECT SERVERPROPERTY('ServerName') AS NewName
If not, fix with:
sp_dropserver '<oldname>';
GO
sp_addserver '<newname>', local;
GO
The error is caused due to mismatch in value between SERVERPROPERTY(‘ServerName’)) and master.dbo.sysservers
Check these SQLs:
SELECT * FROM master.dbo.sysservers
SELECT SERVERPROPERTY('ServerName')
If your SERVERPROPERTY('ServerName') is not any of the sysservers, then the fix is to change your computer name to match one of those.
Adding the server fixes the issue:
DECLARE #ServerName NVARCHAR(128) = CONVERT(sysname, SERVERPROPERTY('servername'));
EXEC sp_addserver #ServerName, 'local';
GO
I had a similar situation, where I have restored a bak file which I got from another windows machine,which retained windows user account with the old PC name. I had delete the backup, create an empty data base and restore into that. This solved my issue
Related
The following error occurs when trying to load the target table (SQL Server)
Server: Msg 544, Level 16, State 1, Line 1
Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF.
The target table has identity column hence it has been failing. And it is not failing for one session which follows same pattern and is in same workflow.
Could you please help me resolve this issue.
You should not connect identity column with any port in target. Leave it unconnected
I have one SQL Server instance accessed by many different applications.
Sometimes happened that one of such application throw the exception : "String or binary data would be truncated".
My objective is to trace (logging) when that error happen, and trace down which application has encountered the problem on which field.
I have no access to every application's code, so my first idea is to develop a solution directly in the SQL Server, but i don't know how can i check if that problem is occured and on which field.
but i don't know how can i check if that problem is occured and on which field.
even SQL server won't tell you on which field it occurred.There is a connect item ,which has been logged for the same
https://connect.microsoft.com/SQLServer/feedback/details/339410/please-fix-the-string-or-binary-data-would-be-truncated-message-to-give-the-column-name
But you can catch those errors,with a simple try catch and log them
create table #t1
(
charcol char(1)
)
begin try
insert into #t1
values
('a'),
('aa')
end try
begin catch
select error_message()
end catch
This is fixed in Recent versions of SQLServer..Now you will be able to know the exact column
Msg 2628, Level 16, State 1, Line 9
String or binary data would be truncated in
table 'StackOverflow2013.dbo.CoolPeople', column 'PrimaryCar'.
Truncated value: '2006 Subaru Impreza '.
This works in SQL Server 2019 if you enable database scoped settings like below
ALTER DATABASE SCOPED CONFIGURATION
SET VERBOSE_TRUNCATION_WARNINGS = ON;
you have to turn traceflag 460 for SQL Server 2016-2017
References and Examples:
https://www.brentozar.com/archive/2019/03/how-to-fix-the-error-string-or-binary-data-would-be-truncated/
I am trying to run a query in SQL Server 2008. It looks like this:
IF EXISTS (SELECT name FROM sysobjects WHERE name = "Bonds" AND type = 'U')
DROP table Bonds
GO
When I run this, I get this error:
Msg 207, Level 16, State 1, Line 2
Invalid column name 'Bonds'.
Msg 28102, Level 16, State 1, Line 3
This query was created by SQL Server. I am trying to run it in a different computer. Then I face this issue.
I have tried Ctrl+Shift+R as this post: SQL Server Invalid Column name after adding new column. But it is not helping.
Need some guidance on this.
Change
WHERE name = "Bonds"
to
WHERE name = 'Bonds'
Otherwise "Bonds" is treated like a column-name which does not exist.
use single quotes in search condition
WHERE name = 'Bonds'
I think you can also use
SET QUOTED_IDENTIFIER OFF;
before your query.
UPDATE:
Running this:
ALTER DATABASE "STRINGSDB.MDF"
COLLATE Latin1_General_CS_AShere
Getting this error:
Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.
Msg 5072, Level 16, State 1, Line 1
ALTER DATABASE failed. The default collation of database 'STRINGSDB.MDF' cannot be set to Latin1_General_CS_AS.
I only have SQL server Management Studio accessing the DB.
ORIGINAL POST:
My SQLEE indicates a Collation of...
COLLATE SQL_Latin1_General_CP1_CS_AS
I am having problems finding the meaning of the CP1, does anyone know what this means?
I also ran...
select * from ::fn_helpcollations()
and the
SQL_Latin1_General_CP1_CS_AS
doesn't exist, also checked...
Latin1_General_CP1_CS_AS
thanks for any help.
From SQL Server Collation Name (Transact-SQL):
CP1 specifies code page 1252
I was running a trace on a Sql Server 2005 using the profiler and need to find out what is causing the reported errors.
I used the "blank" template, and selected all columns of the following events:
Exception
Exchange Spill Event
Execution Warnings
Hash Warnings
Missing Column Statistics
Missing Join Predicate
I noticed a number of these errors in the "TextData" column:
Error: 156, Severity: 16, State: 0
Error: 208, Severity: 16, State: 0
I looked up the errors (Incorrect syntax, Invalid object name), but how can I tell what stored procedure or query is causing them?
Don't worry about the 208 errors. 208 is "Object not found". Profiler picks up these due to what's called 'deferred name resolution'.
Take the following procedure.
CREATE PROCEDURE Demo AS
CREATE TABLE #Temp (ID int)
INSERT INTO #Temp VALUES (1)
SELECT ID FROM #Temp
GO
That proc will run fine without any errors however, if you have a profiler trace running, you'll see one or two instances of error 208. It's because the table #Temp doesn't exist when the proc starts, which is when the code is parsed and bound. The process of binding to the underlying objects fails.
Once the create table runs, the other statements get recompiled and bound to the correct table and run without error.
The only place you'll see that deferred resolution error is in profiler.
in sql 2005 you can't.
you'll have to run the profiler trace of SQL:StmtStarting, SQL:StmtCompleted, User Error Message and Exception events with text, transactionId, EventSequence and otehr columns you need to get a picture of what's going on.