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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Creating dynamic user name/password

Author  Topic 

Pasi
Posting Yak Master

166 Posts

Posted - 2014-05-28 : 18:25:10
HI,

I am trying to use a first_name , Last_name and append this as username something like mike test and create username like 'Mtest@123'. and password as well.

The first_name, last_name comes from a table called "person".

Right now the user name and password is hard coded and I need to make this dynamically generated, is that possible within SQL?

How can I do this within SP? Below is my sp which Tara helped: (thanks Tara).

ALter PROCEDURE PatientEnroll (@person_id AS uniqueidentifier)

AS

BEGIN

SET NOCOUNT ON

INSERT INTO dbo.ngweb_bulk_enrollments(row_id, person_id,practice_id, user_name,password,security_answer,forgot_password_question,forgot_password_answer,created_by,create_timestamp,
modified_by,modified_timestamp)
--SELECT newid(),p.person_id,'0001','gbile','ABc23','Red','color','Red',[user_id],current_timestamp,'',current_timestamp


from person p
inner join user_mstr um on um.practice_id=p.practice_id
inner join nxmd_demographics_ nd on nd.person_id= p.person_id
inner join patient_encounter pe on pe.person_id =nd.person_id
inner join patient d on d.person_id =p.person_id
where p.person_id =@person_id
and email_address <>''

END
GO

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-05-28 : 19:27:46
SELECT newid(),p.person_id,'0001',first_name+last_name,first_name+last_name+'123','Red','color','Red',[user_id],current_timestamp,'',current_timestamp

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2014-05-28 : 19:54:47
Thanks Tara.!

quote:
Originally posted by tkizer

SELECT newid(),p.person_id,'0001',first_name+last_name,first_name+last_name+'123','Red','color','Red',[user_id],current_timestamp,'',current_timestamp

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/

Go to Top of Page
   

- Advertisement -