Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-05-09 : 08:26:48
|
| Ruth Mifsud writes "Hi,I will really appreciate any help on this!!I need to randomly generate a series of characters and I must ensure that the string created does not contain any underscores.I am using NEWID() method to generate the string. Do I need to check for underscores? Or does it never return any? If yes how do I remove them (since underscore is a wild character)? I am using the following sql which is eating up all my string!!!DECLARE @myid uniqueidentifierSET @myid = NEWID()Declare @i intDECLARE @b varchar(50)set @b = CONVERT(varchar(255), @myid)print @bselect @i = patindex('%_%', @b)while @i > 0begin select @i = patindex('%_%', @b) select @b = replace(@b,substring(@b, @i, 1),'') print @bendThanks a lot for your help!Ruth Mifsud" |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2005-05-09 : 08:56:06
|
| NEWID will not generate underscores. It will, however, generate dashes. It is a fixed format value of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where all the xs are hexadecimal characters (0-9, a-f)-------Moo. :) |
 |
|
|
|
|
|