We help IT Professionals succeed at work.
Get Started

Insert Record into a Replicated table with Identity column (PK) via ColdFusion - neec to RESEED replicated table

207 Views
Last Modified: 2017-05-02
SQL Server 2008
CF Server 9

I am trying to insert a record into a replicated table via ColdFusion, but it crashes telling me I cannot add a duplicate Primary Key.   The Primary Key is an IDENTITY column (increment +1).   I know that subscribed tables are supposed to be read only, but I only replicate once a day, so I want to insert a row into the replicated table so the user can see instant information.  This same information gets added to the original table (via script) at the end of each day so it will be in the replicated table in 24 hrs, but I don't want the user to have to 'wait until tomorrow'.

I've figured out that in the replicated table, the identity seems to have reset itself and all I need to do is use:

DBCC CHECKIDENT ( mytable, RESEED )

an it works fine.

My question:  I need this to be automatic.  I assume that each time I Publish/Subscribe, the subscribed table's INDENTITY will be reset back to null again.  Is there any way to have my subscribed table to RESEEDED via ColdFusion before I insert the row?  Or run a script when I Subscribe the table?

Max
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE