title: SQL Converting int to varchar
body: <p>I need help converting an <code>integer</code> to a <code>varchar</code>.</p>
  
  <p>I'm trying to write a procedure that takes in a <code>ProfileID</code> and a <code>Currenttime</code>; using those  two values it finds the start time of the <code>profileID</code> and subtracts <code>currenttime</code> from 
  <code>starttime</code> and returns <code>hours:minutes:seconds</code>.</p>
  
  <p>What am I doing wrong, is there a better way to write this?</p>
  
  <p>Thanks. </p>
  
  <pre><code>CREATE PROCEDURE [dbo].[CalculateElaspedTime]
      -- Add the parameters for the stored procedure here
      @ProfileID nvarchar(10),
      @CurrentDateTime datetime = '' 
  AS
  BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
  
      -- Insert statements for procedure here
      if @CurrentDateTime = CAST('' as datetime)
      set @CurrentDateTime = GETDATE()
  
      DECLARE @StartTime datetime;
      DECLARE @ElaspedTime time;
      DECLARE @hh int;
      DECLARE @mm int;
      DECLARE @ss int;
      Declare @TimeString varchar
      set @StartTime = (Select top 1 [DateTime] From Log WHERE ProfileID = @ProfileID);
      set @hh = DateDiff(hour,@StartTime,@CurrentDateTime);
      set @mm = DateDiff(minute,@StartTime,@CurrentDateTime)-60*@hh;
      set @ss = DateDiff(second,@StartTime,@CurrentDateTime)-60*@mm;
  
      set @TimeString = (Select CAST(@hh as varchar)); -- Fails Here 
      set @ElaspedTime = convert(datetime, cast(@hh as varchar) + ':' + cast(@mm as varchar) + ':' + cast(@ss as varchar));
      INSERT INTO Log (ElaspedTime) Values (@ElaspedTime);
  END
  </code></pre>