SQL Server - Sequence as Primary Key - Create Method

  • 10 April 2021
  • 1 reply
  • 16 views

Badge +10

I need to call Create method on a SMO (based on SQL Server table). Table's primary key is set to use a database sequence. In SMO, create method primary key is flagged as required. So I must provide a value in key field while calling Create method while I want SQL Server to generate sequence and use it as primary key. 

 

How can I SMO Create method to use sequence that is generated at database level and not require pass to Create method when called from K2 form? Primary key is defined as Character as I have to add a string to create primary key.

Thanks 


1 reply

Userlevel 5
Badge +13
My recommendation would be to use a stored procedure to perform your inserts so it can leverage the database to create the new key. K2 works well with numeric Identity columns, but non-identity primary keys become required using the standard create/read/update/delete smartobject templates

Reply