SQL Server - how to fix below error??? - Asked By Giri s on 06-Aug-12 08:27 AM

ALTER procedure [dbo].[db_BackUp]

@Path varchar(500),
@file varchar(50)
as
@file='test.bak'
backup database ULPBC

to disk = @Path + '\' + @file

with init

error:

Msg 102, Level 15, State 1, Procedure db_BackUp, Line 6
Incorrect syntax near '@file'.
Msg 102, Level 15, State 1, Procedure db_BackUp, Line 9
Incorrect syntax near '+'.
Msg 319, Level 15, State 1, Procedure db_BackUp, Line 11
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

pls fix above error..pls guide me friends

Peter Bromberg replied to Giri s on 06-Aug-12 09:06 AM
CREATE procedure [dbo].[db_BackUp]
@Path varchar(500),
@file varchar(50)
as
declare @fullpath varchar(500)
set @fullpath = @Path+'\'+@file

backup database ULPBC to disk = @fullpath with init