Reputation: 9722
I'm migrating data right now and I need to prepare it for the new applicatin. Here is my query:
SELECT pet.member_id, CONCAT( 'full_', pet.member_id, '.', pet.image_ext ) AS post_thumbnail
FROM pet
WHERE pet.image_ext != ""
I need to add a column for an ID ... and the number needs to start at 2000
and increase.
How can I add that to this query?
Upvotes: 0
Views: 74
Reputation: 3833
Try this :
DBCC CHECKIDENT ('[{yourDb}].[dbo].[pet]', RESEED, 2000);
It will reseed your identity column and start it from 2001.
Upvotes: 1
Reputation: 1624
SELECT pet.member_id,
CONCAT( 'full_', pet.member_id, '.', pet.image_ext ) AS post_thumbnail,
@rownum := @rownum + 1 AS ID
FROM pet,
(SELECT @rownum := 1999) r
WHERE pet.image_ext != ""
Upvotes: 0
Reputation: 5084
You can simply add one value with number 1999. Or use:
ALTER TABLE blabla AUTO_INCREMENT=100
Upvotes: 1