开发者

Set trigger to create an auto increment field

My situation: I have a MS CRM 3.0 install that uses MSSQL 2000 SP4 - there are no options for creating auto increment fields inside the entity creation tool. After research I have concluded to do this you need to 1.) use the crm sdk 2.) create a trigger. Currently I do not have the time / means to mess with the sdk so I'm trying to set up a trigger.

I have navigated to MS Enterprise Manager found the table I want to modify, right clicked and selected Manage Triggers. I have also created the INT field via my CRM admin area and queried the DB to set a valu开发者_JS百科e for my "AccountNumber" to 10001 (this way my trigger doesn't have to deal with a null value and can grab this 10001 and + 1 it).

I have tried some code but am unfamiliar with the syntax and the way to grab the previously entered accountnumber and then incrementing it for the record being inserted. (I assume there is an "AFTER INSERT" function?)

Some code examples would be greatly appreciated. Thanks!


MSSQL can do that for you without a trigger. Just define an int/bigint field with IDENTITY(x,y) where x is the initial number (10000) and y is the increment: http://msdn.microsoft.com/en-us/library/aa933196%28v=sql.80%29.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜