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
Related
Using SQL Server 2016. Have a locally hosted database that uses the Windows login for the sa, which is what I am using to login.
Yesterday I ran
CREATE TABLE [Otis].[AnalyzerGroups]
(
[id] [int] IDENTITY,
[Name] [varchar](50) NULL
);
and got command successfully completed. Today I tried selected from this table but got an error:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'Otis.AnalyzerGroups'
So I thought I misremembered and tried running the create statement again but then got the error -
Msg 15530, Level 16, State 1, Line 1
The object with name "AnalyzerGroups" already exists.
The statement has been terminated.
So then I tried DROP TABLE [Otis].[AnalyzerGroups]; and got
Msg 3701, Level 11, State 5, Line 1
Cannot drop the table 'Otis.AnalyzerGroups', because it does not exist or you do not have permission.
I tried making a new test table and the same thing. The first time I run the create statement command successfully completes, but then I can't select / insert / drop from the table, and I cannot see it in the Object explorer either.
I assume this must be some permissions issue but I don't know what property is keeping me from viewing these tables - its not like I'm putting security on these tables, and I can see every other table in our database. Any thoughts?
You put it most likely in the wrong database. Try this.
sp_MSforeachdb 'SELECT "?" AS DB, * FROM [?].sys.tables WHERE name like
''%AnalyzerGroups%'''
There was a trigger in the SQL Server database that fired any time a new table was created under any schema, and would then transfer it to the dbo schema. So my tables did exist, but they were under the schema I was expecting because of this trigger. Why does this trigger exist? Got me. But it's in production and has been for over a decade so there's some reason/it's definitely not changing. Thanks for the help though everyone.
I want to change the DURABILITY of a memory-optimized table in SQL Server 2016 from SCHEMA_AND_DATA to SCHEMA_ONLY.
The Microsoft documentation suggests that the following ALTER TABLE statement should work:
ALTER TABLE mem_opt_table
DURABILITY = SCHEMA_ONLY
But it gives the following error:
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near 'DURABILITY'.
What is the correct syntax for changing the durability setting on a table? Are there any additional steps that I am missing?
The documentation linked in the original question is faulty as was suggested by many of the comments. That is confirmed in the github issue response here: https://github.com/MicrosoftDocs/sql-docs/issues/3523#issuecomment-554511264.
Therefore, the only way to do this is to drop the table and re-create it with the desired DURABILITY setting.
Selecting data from a linked SQL Server returns an error when there is a period in the name of the table.
SELECT *
FROM [LEGOSDB].[LegosDB].[dbo].[MY.Employees]
Results in the following error message.
Msg 7314, Level 16, State 1, Line 2
The OLE DB provider "SQLNCLI10" for linked server "LEGOSDB" does not contain the table ""LegosDB"."dbo"."MY.Employees"". The table either does not exist or the current user does not have permissions on that table.
It works fine when I run a query without a period in the table name.
SELECT *
FROM [LEGOSDB].[LegosDB].[dbo].[BankingInfo]
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
I want to run the following rename
EXECUTE sp_rename N'dbo.Semesters.IsPublic', N'Tmp_ShowNCs', 'COLUMN'
I get the error
Msg 4928, Level 16, State 1, Procedure sp_rename, Line 547
Cannot alter column 'IsPublic' because it is 'REPLICATED'.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
I have enabled change data capture (CDC) for this table. Probably thats why this column is "replicated". SSMS shows replicated = yes.
So I want to know if this is normal or a bug. I want to keep CDC on but rename this column. Do I have options other than deleting existing CDC information and re-enabling CDC?
you did in wrong order. You have to turn off CDC on table (CDC on DB is turned on), then change column, then turn On CDC on table.
To undo your problem you have to turn on CDC on DB, then on table, turn off CDC on table, rename column, turn on CDC on table.