AutoIncrement on MSSQL 05?

Hi Folks - don’t know if I’ve completely lost my marbles now, but I’m struggling with the most basic SQL.

I created a new table - initially in Servoy and set the relevant column types including two with Servoy Sequences. Then realised I really needed to populate this table with data from one of the other tables and I wasn’t sure how to do that in Servoy developer, so quickly rebuilt it (only 4 columns) in SQL Server with the area_id column as a ‘uniqueidentifier’.

Ran my SQL INSERT in SQL Server Manager and the insert failed because the area_id cant be null. Of course I know it cant be null, but I was expecting the uniqueidentifier to be automatically updated for each row.

I deleted the area_id in the thought that I could then run it in Servoy and it would update the rows with a Servoy Sequence once I added it as a new field to the table - but again that’s not available.

If I build this as an empty table again in Servoy, is there an easy way to write and run the SQL INSERT statement taking advantage of the Servoy Sequences - to get this column auto-incrementing ? Do I need to create a special form to attach methods to to do that?

Hi Kahuna

May not be the most efficient way but for one-offs this should get you going:

set the MySQL _ID fields to auto-increment using Navicat/MySQL Admin etc
do the import
remove the MySQL auto-increment settings
open the table in Servoy, set for Servoy sequence and syncronise (so that Servoy knows the next ID)

HTH

grahamg:
Hi Kahuna

May not be the most efficient way but for one-offs this should get you going:

set the MySQL _ID fields to auto-increment using Navicat/MySQL Admin etc
do the import
remove the MySQL auto-increment settings
open the table in Servoy, set for Servoy sequence and syncronise (so that Servoy knows the next ID)

HTH

Thank’s Graham - that was what I was stuck on. I’d forgotten that you need to set the column to int, then identity and then add a seed increment figure. Don’t they make it complicated :wink:

A steady hand at the tiller as ever - cheers Bud