SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Update a column with random number
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

matrixrep
Starting Member

29 Posts

Posted - 11/07/2012 :  13:55:55  Show Profile  Reply with Quote
I have a stored procedure that generate a password the way i want.

I want to update the field password in a table containing 3 columns (userID, name, password)

What is the best way to put a different password for each userid ?

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/07/2012 :  14:09:21  Show Profile  Reply with Quote
Easier if you can make the query in-line, or convert it into a function rather than a stored proc. If you were to convert it to a function, then you can do something like shown below:
UPDATE y SET
	y.Password = f.Password
FROM
	YourTable y
	CROSS APPLY dbo.YourFunction(userId,[name]) f
Go to Top of Page

matrixrep
Starting Member

29 Posts

Posted - 11/07/2012 :  14:33:15  Show Profile  Reply with Quote
I need to use my stored procedure.
Go to Top of Page

jimf
Flowing Fount of Yak Knowledge

USA
2870 Posts

Posted - 11/07/2012 :  15:31:39  Show Profile  Reply with Quote
Could you make your stored procedure a function? A function is more appropriate for this task.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

matrixrep
Starting Member

29 Posts

Posted - 11/08/2012 :  09:10:04  Show Profile  Reply with Quote
I cannot use a function. My stored procedure generate only a random password.
Go to Top of Page

matrixrep
Starting Member

29 Posts

Posted - 11/08/2012 :  09:37:35  Show Profile  Reply with Quote
Thanks for your help


Declare @Password nvarchar
UPDATE MyTABLE
SET Password = dbo.Myfunction(@Password)
WHERE ...

That did the trick for me.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000