The method of SQL server backup database stored procedure

Time:2020-10-29

SQL Server batch export stored procedures

In the query analyzer, select database, right-click task, and select generate script from the pop-up menu

——》”Next step” — “select the database where you want to store the procedure”

“Next step” — check “stored procedure” and “next step”

Check the name of the stored procedure you want to generate, and then go to the next step

Select to save the script to a file, and select the save path

Another method is directly implemented by SQL statements


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
 
 
ALTER PROCEDURE [dbo].[dbBak]  
 
AS 
BEGIN 
  DECLARE @sqlCommand NVARCHAR(1000) 
  DECLARE @dateTime NVARCHAR(20) 
  SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + 
  REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')  
  SET @sqlCommand = 'BACKUP DATABASE BLNBusyData TO DISK = ''D:\DataBaseBakUp\bln_' + @dateTime + '.BAK''' 
  EXECUTE sp_executesql @sqlCommand
END

Recommended Today

Go learning notes map (Dictionary)

1. Declaration assignment: var m1 map[string]int m1 = map[string]int{“name”:1, “xxx”:2} be equal to m1 := make(map[string]int) be equal to m1 := map[string]int{} //m2 := map[string]interface{}{} 2. Map is a reference type m2 := m1 m2[“age”] = 18 //Results of M1: Map[ age:18 name 1 xxx:2 ] 3. Determine whether the map value exists OK, it’s […]