Invalid column name 'vTime'. while creating a backup script

  • Hi,

    I am trying to do a remote backup

    use master

    go

    Declare @vBackupPath varchar(255)

    Declare @vDate varchar(85)

    Declare @vTime varchar(85)

    set @vDate = CONVERT(VARCHAR(8), GETDATE(), 112)

    set @vTime = LEFT(REPLACE(convert(varchar, getdate(), 108), ':', ''),4)

    --set @vTime = '0030'

    --select @vDate+@vTime

    set @vBackupPath ='\\l04\backup\RightFax_backup_'+@vDate+vTime+'.bak'

    backup database RightFax

    to disk = @vBackupPath

    go

    I keep getting error message as invalid column name 'vTime' any help would be greatly appreciated.

    Thanks

  • copy paste error; your variable is missing the @:

    set @vBackupPath ='\\l04\backup\RightFax_backup_'+@vDate+vTime+'.bak'

    should be

    set @vBackupPath ='\\l04\backup\RightFax_backup_'+@vDate+@vTime+'.bak'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Oh what a miss.. Thank you for catching it.

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

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