So far so good. Now let’s throw in a twist. Let’s call it through a linked server.INSERT INTO [(local)\sql2014cs].Test.dbo.IdentTest VALUES ('Col1','Col2');
Msg 213, Level 16, State 1, Line 4
Column name or number of supplied values does not match table definition.
Well that’s a bit odd, right? I mean I used that exact command in the previous test. Turns out that when you do an insert across a linked server that identity column is not ignored. Which means we just need to include the identity value right? Nope.INSERT INTO [(local)\sql2014cs].Test.dbo.IdentTest VALUES (1,'Col1','Col2');
Msg 7344, Level 16, State 1, Line 4
The OLE DB provider “SQLNCLI11” for linked server “(local)\sql2014cs” could not INSERT INTO table “[(local)\sql2014cs].[Test].[dbo].[IdentTest]” because of column “Id”. The user did not have permission to write to the column.
Click through to see how to do this.