Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote this stored procedure for making a back up from database but it doesn't work. Is there anyone who knows how I could correct it?

SQL
ALTER PROCEDURE [dbo].[makebackup]
    -- Add the parameters for the stored procedure here
    @path nvarchar(50)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    backup database[elm]to disk _@path with init
END
Posted
Updated 6-Mar-10 22:43pm
v2

SQL
BEGIN  
  BACKUP 
      DATABASE [YOUR_DB] 
  TO 
      DISK = @Path
  WITH 
      NOFORMAT, INIT, NAME=@BackUpName 
END
 
Share this answer
 
Read an article here[^].
 
Share this answer
 
thank you for your answer.
I tested your suggestion but it take this error:

SQL
SELECT *
INTO elm_backup IN 'backup.mdb'
FROM elm.mdf



Msg 156, Level 15, State 1, Procedure testbackup, Line 16
Incorrect syntax near the keyword 'IN'.

see I want to give it a path to save back up in my path.
 
Share this answer
 
use this query

SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_tablename


for example

SELECT *
INTO Persons_Backup IN 'Backup.mdb'
FROM Persons



if you get your answer then please rating me..

thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900