Home Forums SQL Server 2008 T-SQL (SS2K8) Add Auto Incrementing column to my SELECT statement RE: Add Auto Incrementing column to my SELECT statement

  • You can generate number on fly without using identity:

    SELECT CONVERT(VARCHAR(6), GETDATE(), 12) + 'GP' +

    RIGHT('00000' + CAST(ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS VARCHAR), 5) AS [ImportID]

    , *

    FROM sys.columns

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]