Wednesday 15 October 2014

You receive an “Explicit value must be specified for identity column” error message when you use the replication feature to run an INSERT statement on a table in SQL Server



If you are facing this error "You receive an “Explicit value must be specified for identity column” error message when you use the replication feature to run an INSERT statement on a table in SQL Server" when you are running transaction replications, here is the reason behind this.

You are trying to insert a row in the secondary server where the table property "NOT FOR REPLICATION" option is enabled.
To work around this issue, disable the NOT FOR REPLICATION option for the IDENTITY column.
Here is how we can check the value:

The "Not For Replication" setting for identity columns allows replication to pass the ID value from the publisher to the subscriber without the subscriber creating a new ID.  Since identity columns will always generate a new number when records are inserted, this setting allows you to ensure the values on both your publisher and subscribers stay in synch.
This option can be set when designing or creating a new table as shown below in the highlighted section.
Right click on the table in the secondary server, click on Design in context menu,
check in the properties whether the "NOT FOR REPLICATION" property is set to "yes".
 



If this value is set to "yes" change it to "no" using the below script

declare @objid int
select @objid = object_id('Adventureworks')
exec sys.sp_identitycolumnforreplication @objid, 0

The above query will set the "NOT FOR REPLICATION" property to "No". Once you set the value you need to perform the reinitialize the replication to get all the old values.

Ref. MSDN Article: http://support2.microsoft.com/kb/908711
http://www.mssqltips.com/sqlservertip/1274/change-not-for-replication-value-for-sql-server-identity-columns/
0

Monday 23 June 2014

Identify Missing Sequence Numbers SQL Server



There are many scenarios where we may in need to identify the missing numbers in the provided range.

Here is the quick query which help in identifying using CTE [Common Table Expression]:

DECLARE @Test TABLE
(
Num INT
)

INSERT INTO @Test VALUES (1)
INSERT INTO @Test VALUES (2)
INSERT INTO @Test VALUES (4)
INSERT INTO @Test VALUES (5)
INSERT INTO @Test VALUES (8)
INSERT INTO @Test VALUES (9)
INSERT INTO @Test VALUES (10)

--Get the Missing Numbers from the sequence
;WITH Missing (minid, maxid)
AS
(
SELECT 0 AS minid, 10
UNION ALL
SELECT minid + 1, maxid FROM Missing
WHERE minid < maxid
)
SELECT minid
FROM Missing
LEFT OUTER JOIN @Test tt on tt.Num = Missing.minid
WHERE tt.Num is NULL
OPTION (MAXRECURSION 0);

Result:
minid
0
3
6
7
0

Thursday 22 May 2014

Content within this application coming from the website listed is being blocked by internet explorer




This error seems like problem with Internet Explorer, but you will be getting this error due to the setting in the Outlook in most of the cases.



To over come this error, you need to change the People Pane setting in the outlook.
Follow the below steps:
1. Open outlook.
2. Goto to the View tab
3. Click on the People Pane and make it "Off".

This works for me. :)







0