Create random string

Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.

  1. #1

    Default Re: Create random string


    Hi,

    substring(newid(),0,8)

    "Jason Davis" <jasondavis19@hotmail.com> wrote in message
    news:uyGV9pFSDHA.1552@TK2MSFTNGP10.phx.gbl...
    > How can I create a random (not necessarily unique) - 8 character string?
    > Thanks!
    >
    >

    Ivar Guest

  2. Similar Questions and Discussions

    1. Create string from vars
      DisplayMonthYear.text = months & ' ' & calendar.getFullYear(); What is the proper way to joing vars into a string output...the code above...
    2. Create a random number (ASP VBScript)
      I need to create a random number to use with the .swf so IE doesn't cache my files: <param name="movie" value=".file.swf?nochache=<% random number...
    3. create a random password?
      Is there a tutorial (or an extension) that will explain how to create a random password (and/or username) insert it into an Access database then...
    4. Cannot create an object of type 'System.String[]' from its representation 'String[] Array'
      Hello, I am designing a .net custom control in VS.net 7.1 and my control exposes an array of strings which are supposed to be the items to show. To...
    5. substitute three random words in a string
      Hudson wrote: (someone else wrote:) Quick and efficient with no need for an "e" switch.
  3. #2

    Default Create random string

    How can I create a random (not necessarily unique) - 8 character string?
    Thanks!


    Jason Davis Guest

  4. #3

    Default Re: Create random string

    > substring(newid(),0,8)
    Doesn't work: "The data type uniqueidentifier is invalid for the substring
    function."

    This is OK though:
    SELECT LEFT(CAST(NEWID() AS VARCHAR(36)),8)

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --



    David Portas Guest

  5. #4

    Default Re: Create random string

    Here is code for a SP that generates a random string:

    [url]http://vyaskn.tripod.com/code/password.txt[/url]

    Regards,
    Brad

    "Jason Davis" <jasondavis19@hotmail.com> wrote in message
    news:uyGV9pFSDHA.1552@TK2MSFTNGP10.phx.gbl...
    > How can I create a random (not necessarily unique) - 8 character string?
    > Thanks!
    >
    >

    Brad M. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139