add getdate() at end of expression

  • Hello I m trying to achieve something like this without patindex

    DECLARE @source_path nvarchar(1000)

    SET @source_path = 'hello_there_123.zip'

    PRINT @source_path

    --Expected Result is using getdate() add date before .zip

    SELECT @source_path = hello_there_123_08092016.zip

    Please help. Thanks.

  • dallas13 (8/9/2016)


    Hello I m trying to achieve something like this without patindex

    DECLARE @source_path nvarchar(1000)

    SET @source_path = 'hello_there_123.zip'

    PRINT @source_path

    --Expected Result is using getdate() add date before .zip

    SELECT @source_path = hello_there_123_08092016.zip

    Please help. Thanks.

    Like this:

    DECLARE @source_path nvarchar(1000),

    @Date char(9);

    set @Date = '_' + convert(char(8),getdate(),112);

    SET @source_path = stuff('hello_there_123.zip',patindex('%.zip','hello_there_123.zip'),0,@Date);

    PRINT @source_path

  • dallas13 (8/9/2016)


    Hello I m trying to achieve something like this without patindex

    DECLARE @source_path nvarchar(1000)

    SET @source_path = 'hello_there_123.zip'

    PRINT @source_path

    --Expected Result is using getdate() add date before .zip

    SELECT @source_path = hello_there_123_08092016.zip

    Please help. Thanks.

    Why the aversion to using patindex? When doing string manipulations it's a pretty basic & important function.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • Y.B. (8/9/2016)


    dallas13 (8/9/2016)


    Hello I m trying to achieve something like this without patindex

    DECLARE @source_path nvarchar(1000)

    SET @source_path = 'hello_there_123.zip'

    PRINT @source_path

    --Expected Result is using getdate() add date before .zip

    SELECT @source_path = hello_there_123_08092016.zip

    Please help. Thanks.

    Why the aversion to using patindex? When doing string manipulations it's a pretty basic & important function.

    Wow, I missed that part about not using PATINDEX.

  • Thanks guys.

    Patindex is not supoorted in ssis i guess. So if i use this in ssis then it may be prob. but i think i understand the logic here and thanks again.

  • dallas13 (8/9/2016)


    Thanks guys.

    Patindex is not supoorted in ssis i guess. So if i use this in ssis then it may be prob. but i think i understand the logic here and thanks again.

    Well, you didn't say anything about this needing to be done in SSIS. It appeared you had a SQL question and you got a SQL answer.

  • You can use FindString in SSIS since you are looking for '.zip' in the string.

Viewing 7 posts - 1 through 6 (of 6 total)

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