Friday, March 16, 2012

How to update column value with auto increment number or unique number


Using this query we can update any column value with any unique number with n number of  digit.
==================================================

DECLARE @counter varchar(max)
SET @counter = 1000000000
UPDATE TableName
SET @counter = ColumnName = @counter + 1

Using this query you can update with string character to any of the column value
==================================================

Put table name , column name and give a identity column value.

UPDATE TableName
SET ColumnName = 'Test_User_' + convert(varchar,IdentityColumnName)
SELECT * FROM TableName

1 comment:

  1. Thanks for this and please keep posting this type of queries.

    ReplyDelete

Share your thoughts....