title: This code isnt setting certain values
body: <p>So I'm writing some proceedures for tsql to get a group project back off the ground, and am trying to write something to create user profiles with salted passwords. However, when I run this code, the values for @seedno and @saltval never get set, so my hashed password ends up with a null value. Is there anyone who can help? </p>
  
  <pre><code>CREATE PROCEDURE [dbo].[CreateCustomerAccount]
      @companyName nvarchar (50),
      @emailAddress nvarchar(50),
      @password nvarchar (100),
      @Addr1  nvarchar (50),
      @Addr2  nvarchar (50),
      @Addr3  nvarchar (50),
      @postCode nvarchar (11),
      @Telephone NVARCHAR (20),
      @vatNo NVARCHAR (20) 
  
  AS
      SET NOCOUNT ON
  
      --Declare some variables here
      DECLARE     
          @pwdSalt NVARCHAR (25),
          @Seed INT,                                  /* this is going to store the randomly generated seed we will use to make the salt */
          @CurrentChar CHAR,
          @SaltedPwd NVARCHAR (125),
          @LoopCountVar TINYINT,                      /*because counting is fun, kids :). */
          @Seedno integer,
          @saltval CHAR 
  
  
  
  
          --Generate a seed using the customers email address and a psuedo random number generator.
  
          SET @LoopCountVar = 0;
  
          WHILE @LoopCountVar &lt;= LEN(@emailAddress)
              BEGIN
                  SET @CurrentChar = SUBSTRING(@EmailAddress, @LoopCountVar, 1)
  
                  SET @Seedno = (ASCII(@currentChar)*CRYPT_GEN_RANDOM(10000))
  
                  SET @Seed = @Seed + @Seedno   --Add the integer value of the current character multiplied by a random number between 0 and 100,000 to the seed
  
                  SET @LoopCountVar = @LoopCountVar+1
  
              END;
  
      --Now, populate our salt string by inserting random characters using the seed we just created.
      SET @LoopCountVar = 0;
  
      while @loopCountVar &lt;= 25
      BEGIN
          SET @saltval = CHAR (ROUND((RAND()*94)+32,3))
          SET @pwdSalt = @pwdSalt + @saltval
          SET @LoopCountVar = @LoopCountVar+1 
      END;
  
      --Time for delicious delicious salted hash
      Set @SaltedPwd = @pwdSalt+@password;
  
      -- Insert data into table
      Insert into Customer (orgName, Email, AccountPwd, PwdSalt, AddressLine1, AddressLine2, AddressLine3, PostCode, TelephoneNo, VATNo)
      VALUES (@companyName, @emailAddress, HASHBYTES('MD5', @SaltedPwd), @pwdSalt, @Addr1, @Addr2, @Addr3, @postCode, @Telephone, @vatNo);
  RETURN 0
  </code></pre>