Avatar of w3brang3r
w3brang3r
 asked on

string operation

I need to create bulk users say 500.

so while creating, coming to the passwords....

we use substring(lower(master.dbo.fn_varbintohexstr(hashbytes('MD5','yulkpassword'))),3,32)

which assigns password as password and yulk is the username.....

for eg: if username is rock, we put rockpassword in the above script, so password will be password for rock.

Now, I am developing a storedproc to use for 500 creation activity.

Issue is how to replace the first 4 chars with the username in the above query.....

Please provide solution asap....with proper example.....
Microsoft SQL ServerMicrosoft ApplicationsMicrosoft Development

Avatar of undefined
Last Comment
w3brang3r

8/22/2022 - Mon
peea

??

LEFT(username, 4) + "password" does not work??
tim_cs

Should just be able to do this.  

substring(lower(master.dbo.fn_varbintohexstr(hashbytes('MD5',UserNameField + 'password'))),3,32)

Where UserNameField is the users name.
w3brang3r

ASKER
None of them works!

Thing is I would like use a variable in place of the username part, so that sproc can be developed.....

please reply.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
w3brang3r

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
w3brang3r

ASKER
Got the solution.....using 2 variables.....thanks all.
w3brang3r

ASKER
It was more easy and appropriate.