string operation

w3brang3r
w3brang3r used Ask the Experts™
on
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.....
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
??

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

Commented:
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.

Author

Commented:
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.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Like to also have a confirmation,

Assuming username is user, password is demo

Q1:
DECLARE @XYZ VARCHAR(20);
SET @XYZ = userdemo;
Now using,
substring(lower(master.dbo.fn_varbintohexstr(hashbytes('MD5',@XYZ))),3,32)

Q2:
substring(lower(master.dbo.fn_varbintohexstr(hashbytes('MD5','userdemo'))),3,32)

Is Q1=Q2 ????

Author

Commented:
Got the solution.....using 2 variables.....thanks all.

Author

Commented:
It was more easy and appropriate.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial