Hello Guys:

I got a Stored Procedure working to do what I wanted, but I have a feeling it is an 
amateurish type procedure.  

I was wondering if anyone could let me know if this is a pretty good procedure, or one 
that needs some improving.  I am going to list the procedure below and would 
appreciate any help you might be able to provide:

CREATE PROCEDURE dbo.InsertUserApplications
  @UserID  Integer, 
  @String  Varchar(1000)

AS

DELETE FROM tblUserApplications WHERE UserID = @UserID
DECLARE @AppID Varchar(2)
        
WHILE LEN(@String) > 0
        BEGIN
        SET @AppID = LTRIM(SUBSTRING(@String, 0, CHARINDEX(', ', @String)))
        SET @String = RIGHT(@String, LEN(@String) - CHARINDEX(', ', @String))
        IF LEN(@AppID) = 0 
                BEGIN
                        SET @AppID = LTRIM(@String)
                        INSERT INTO tblUserApplications(UserID, ApplicationID)  
                               VALUES (@UserID, @AppID)
                        BREAK
                END
        ELSE
                INSERT INTO tblUserApplications(UserID, ApplicationID) VALUES 
                       (@UserID, @AppID)
        END
GO



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~-> 

---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to