autoincrement

copy an identity column into another table

I have 2 tables that are related,both have identity columns for primary keys and i am using a vb form to insert data into them,My problem is that i cannot get the child table to get the primary key of the parent table and use this as its foreign key in my database. the data is inserted fine though no foreign key constraint is made.I am w...

Periodic restarting auto numbering for SQL Server

I have a requirement for a program I'm working on to store job numbers as YY-###### with incrementing numbers starting at 000001 in each year preceded by the last two digits of the year. The only method I've been able to come up with is to make a CurrentJob table and use an identity column along with the last two digits of the year an...

If I have a table with only an auto-increment column, how do I insert into it?

A colleague asked me, if you have a table in SQL Server with only an auto-increment column, how do you insert a new row into that table? INSERT INTO MyTable() VALUES() ...doesn't work. As for why... I'm not really sure. But I found the question kind of compelling. ...

Firebird and IBCTable

Hello. I am trying the devart ibdac components but I am having a little issue with the IBCTable component. On tables with autoinc (trigger based) when I try to post the data it says that the field with the autoincrement must have a value, whereas if I use a SQL query to insert it everything works fine. Is there any workaround for this? ...

Rails Rake MySql Autoincrement Problem w db:fixtures:load

I'm trying to load some Rake Fixtures (rake db:fixtures:load) into a MySql database and I'm seeing some weird behaviour with AutoIncrement values. Normally this goes up by 1 for each insert which allows me to define/create tests. (BTW - normal create/insert from script works correctly). However when I load from fixtures the id field is ...

Are there any new ODBC options for Foxpro?

We commonly use MS Visual Foxpro v9.0 SP1, the language, tables, and reports. However, sometimes we use an ODBC driver to connect to the tables. The ODBC driver was written for Foxpro v6, and doesn't support certain nested selects, autoincrement fields, or embedded casts. We would like to find an alternative to what we have. It could...

looking how to realise a primarykey in a xml schema with autoincrement function

At the beginning i wrote a c# class. Then i created a schema for the class with the “xsd.exe” tool. I posted this schema into the schema collection of my database and created a new xml column: CREATE XML SCHEMA COLLECTION AppointmentSC AS 'its impossible to insert a schema here in the forum' GO ALTER TABLE Adresse ADD xmlAppointment XM...

Where should one place the code to autoincrement a sharded counter on Google App Engine/Django when one creates a new model?

I've a model MyModel (extending Google's db.Model), and I want to keep track of the number of Models that have been created. I think the code at from Google's I/O talk on Sharding Counters is quite good, so I'm using that. But I'm not sure where I ought to be calling the increment when creating a new code. (I'm using Django, and I've ke...

How to update all the autoincrement columns in a DataTable?

I have a DataTable with an "Id" column, which is an identity column in our SQL Server 2005 database. This column has the AutoIncrement property set to true. I don't fill the table with data from the DB, since I use it only for inserts, so it assigns bogus Ids starting from 1. But after I call the tableAdapter.Update(), I'd like to have ...

C#/SQL get autoincremented field value

I have a table with autoincremented primary key. In my code I am trying to receive the new autoincremented value when I execute each 'insert' query. Is there a way to do it programatically? Thanks. UPD: Assume I have a table: TABLE User ( userID INT NOT NULL AUTO_INCREMENT, name VARCHAR( 25 ) NOT NULL , email VARCHAR( 50 ) NOT NULL , U...

Can I create a Rails model where the ID auto-increments from 0, not 1?

Can I create a Rails model where the ID auto-increments from 0, not 1? How? Are there any gotchas? I checked here, and it seems I can't: http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#M001911 If, as it seems, I cannot, is there reason why I can't or shouldn't just manually assign an ID of 0 to ...

SubSonic PrimaryKey not autoincrement

Does current version of SubSonic support PrimaryKey (Int) which is not Autoincrement? How? PS: If I don't use SimpleRepository() I can save new record with assigned Id so more or less I can go on, thz. ...

MySQL - second sequence in table (e.g. by category)

Hi all, I'm trying to find the most efficient way to do something and would appreciate your advice! I have a table with the following columns: id category category_sequence other_columns id is an auto-increment column and the primary key. The category is selected by the user on the UI. What I'd like to do is generate a category_seq...

DDLUtils and autoincrement values

When trying to use DDLUtils it always seems to take over the id values for the columns that are set to autoincrement. How can I prevent this? For example, I have a Dogs table with a column called ownerID. The column ownerID is set to autoincrement. However my list of owners is not continuous, there are gaps (for example, ownerID's 2, 4,...

Get current auto_increment value

I am doing mysql insert for my table using php. Autoincrement column name is "link_id" and "alias" colum is used to make SEO friendly url. During my insert, I would like to attach link_id value at the end of my alias column. So I need to know what is the being inserted link_id value. I do not want to do another query. mysql_insert_id...

What is an elegant way to make two fields auto increment?

In SQL Server, I have two fields, one is primary and has an identity (AN_ID) then I have another one that for legacy reasons (don't ask) has to be updated reflecting the AN_ID. Currently they have the exact same value. I was wondering if there are pure T-SQL query (no stored procedures) to make it auto incremente. Thank you very much E...

Change the step auto_increment fields increment by

How do I change the amount auto_increment fields in MySQL increment by from the default (1) to n? ...

How to add an increment(1) to the value of an element with JQuery

<span id="shortfall" style="color:black">$row[shortfall]</span> How to increase $row[shortfall] to $row[shortfall]+1 with JQuery? ...

postgresql nextval generating existing values

I had to migrate from a mySql based ruby on rails app to using postgresql. No problems but one so far, and I don't know how to solve it. The migration of data brought ids along with it, and postgresql is now having problems with existing ids: it's not clear to me where it gets the value that it uses to determine the base for nextval: i...

MySql autoincrement column increases by 10 problem

I am a user of a some host company which serves my MySql database. Due to their replication problem, the autoincrement values increses by 10, which seems to be a common problem. My question is how can I simulate (safely) autoincrement feature so that the column have an consecutive ID? My idea was to implement some sequence mechanism ...