Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 11th, 2005, 12:46 PM
kdog kdog is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: New York
Posts: 1 kdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help PLEASE

Hi,

I am looking to populate a password field in a table that consists of only three fields: pernr, userid, password. This table is used as a base table for a web app. Whenever someone within the company wants to login to an internal web app they retrieve their password from this underlying SQL table. Every night a run a DTS package that adds rows or deletes rows of employees who just started with the company or who are leaving. For those that are starting, I populate the pernr and userid fields from base tables in the database. The password field is a randomly generated 9 digit field. I have copied script from another site written by Narayana Vyas Kondreddithat. It is a stored procedure that can output what i need.

EXAMPLE: CREATE PROC random_passwordcode
(
@len int = 9, --Length of the password to be generated
@password_type char(7) = 'complex'
)
AS
BEGIN
DECLARE @password varchar(25), @type tinyint
SET @password=''
WHILE @len > 0
BEGIN
IF @password_type = 'complex'
BEGIN
SET @type = ROUND(1 + (RAND() * (3)),0)
IF @type = 1 --Appending a random lower case alphabet to @password
SET @password = @password + CHAR(ROUND(48 + (RAND() * (9)),0))
ELSE IF @type = 2 --Appending a random upper case alphabet to @password
SET @password = @password + CHAR(ROUND(48 + (RAND() * (9)),0))
ELSE IF @type = 3 --Appending a random number between 0 and 9 to @password
SET @password = @password + CHAR(ROUND(48 + (RAND() * (9)),0))
ELSE IF @type = 4 --Appending a random special character to @password
SET @password = @password + CHAR(ROUND(48 + (RAND() * (9)),0))
END
SET @len = @len - 1
END
SELECT @password --Here's the result
END

exec random_passwordcode

Now what I want to do is loop through this code every time I add a new row (some nights we don't add any rows, other nights we may add 10 rows) to my table to populate a random password for each new employee. Can someone please help me with this. Do I use a curso? A trigger? Could I simplify this code to work in an update statement? Thanks for any help you can give.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Help PLEASE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT