T-SQL Store procedure variable

  • Hi
    Sorry a bit new to T-SQL!

    I have the following store procedure
    EXECUTE sp_sqlbackup @databases = 'all', @URL = 'https://storage.blob.core.windows.net/sqlbackup', @Credential = 'Backup', @Backup = 'FULL'

    I would like to execute with variable for @URL, so instead of having @URL = 'https://storage.blob.core.windows.net/sqlbackup' having something of the lines of

    variable = 'https://storage.blob.core.windows.net/sqlbackup'
    EXECUTE sp_sqlbackup @databases = 'all', @URL = variable, @Credential = 'Backup', @Backup = 'FULL'

    Can this be done?

    Regards

  • Raxso1 - Friday, October 6, 2017 12:08 PM

    Hi
    Sorry a bit new to T-SQL!

    I have the following store procedure
    EXECUTE sp_sqlbackup @databases = 'all', @URL = 'https://storage.blob.core.windows.net/sqlbackup', @Credential = 'Backup', @Backup = 'FULL'

    I would like to execute with variable for @URL, so instead of having @URL = 'https://storage.blob.core.windows.net/sqlbackup' having something of the lines of

    variable = 'https://storage.blob.core.windows.net/sqlbackup'
    EXECUTE sp_sqlbackup @databases = 'all', @URL = variable, @Credential = 'Backup', @Backup = 'FULL'

    Can this be done?

    Regards

    Sure it can.
    DECLARE @URL1 varchar(200) =  'https://storage.blob.core.windows.net/sqlbackup'
    EXECUTE sp_sqlbackup @databases = 'all', @URL = @URL1, @Credential = 'Backup', @Backup = 'FULL'

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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