Covert auto ID to file name

  • I need to convert auto ID to a file name.

    For example, file name's length will be 8 characters such as 00000123, 00000056, 01234568. Here, 123, 56 or 1234568 are come from auto ID.

    How to code it?

  • Something like

    SELECT RIGHT(100000000 + ID, 8)

    FROM YourTable



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • here's an example of two different techniques that do the same thing:

    /*ANewIDDiffID

    0000012300000123

    0000005600000056

    0123456801234568

    */

    With MySampleData (TheID)

    AS

    (SELECT 123 UNION ALL

    SELECT 56 UNION ALL

    SELECT 1234568 )

    SELECT

    REPLACE(STR(TheID,8),' ','0') As ANewID,

    RIGHT('00000000' + convert(varchar,TheID),8) As DiffID

    From MySampleData

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply