@variables

  • I am trying to combine two variables into one.

    Declare @path char(50), @path1 char(50)

    Declare @file char(50)

    select @path = '\\server\server1\'

    select @file = 'file.txt'

    select @path1 = @path+@file

     

    It doesn't pick up the file name as part of @path1

  • Change your char() to varchar(), or trim the variables.  You are trying to concatenate 2 50 character fields into 1 50 character field.  They do concatenate, but with 33 space characters in between, and are then truncated to first 50 characters. 

    So either:

    Declare @path varchar(50), @path1 varchar(50)

    Declare @file varchar(50)

    select @path = '\\server\server1\'

    select @file = 'file.txt'

    select @path1 = @path+@file

    Or:

    select @path1 = RTRIM(@path)+ RTRIM(@file)

    Hope this helps



    Mark

  • That did it,  thank you

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply