concatenation issues

  • Hi all,

     

    Man this has been a frustrating day. I think I've gotten to the root of the latest problem, but it makes NO sense to me.

    Let me explain - I am building up a string to give a filelocation to a SP that will extract the data from the excel spreadsheet, into a table. The excel spreadsheet name will change daily, based on date. I've got the excel extraction working, more or less, but I've run into a string concatenation problem I cannot understand, or see.

    I have played around, change data type for @filename from Varchar(250) all the way down to a char the is exactly the same length. The problem seems to be around the concatenation of the @dateformat into the @filename, but I cannot see why, for the life of me...

    --****code below****

    set nocount on

    go

    declare @filename char(46)

    --declare @sheetname varchar(100)

    declare @dateformat char(8)

    declare @dir  varchar(250)

    select @dateformat = convert(char(2),(datepart(day,getdate()) -1))

     +substring(convert(char(3),(datepart(month,getdate()) +100) ),2,2)

     +convert(char(4),datepart(year,getdate()))

    select @dateformat=ltrim(rtrim(@dateformat))

    if (@dateformat = '17062004')

     print 'They are the same'

    else

     print 'what is different?'

    select @filename = '\\reports\reports\test_e\a'+@dateformat+'peragt04.xls'

    select @filename

    if (@filename = '\\reports\reports\test_e\a17062004pergat04.xls')

     print 'They are the same'

    else

     print 'what is different?'

    select @filename=left(@filename,len(@filename))

    select @filename

    select '\\reports\reports\test_e\a17062004pergat04.xls'

    if (@filename = '\\reports\reports\test_e\a17062004pergat04.xls')

     print 'They are the same'

    else

     print 'what is different?'

  • found my folly - a typo, as usual!

    a17062004perAGT04 versus

    a17062004perGAT04

     

    oh well, off to more fun

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

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