-
How to create a number of record in an SQL query?
Tell me please how to get the sequental number of record in query. I need to create a query that contains a field in that is the sequental number of the record in the query. I've found an idea only how to do it in update but I need it in insert. Update after insert is impossible because I need to store such number of record into a primary key. That idea consists in using construnction @intCounter = fieldname = @intCounter + 1 but insert operator can't use = operator. I need in this query insert into one table data selected from other one. The function INDENTITY requires SELECT INTO construction that as I've understood going to create new table but I need to add into existing table so such construction I don't know how to make working.
-
You can create an INDENTITY column on the table and it will automatically populate the table rows with sequential values.
Use ALTER TABLE ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|