Hello
I am new to admin of sql. will be responsible for backups etc. I am trying out a script from a FAQ. and it requires me to run sp_foreachdb with a created stored proc:
CREATE procedure usp_BackupDatabase
@DatabaseName varchar(100)
as
declare @date varchar(10)
declare @BackupPath varchar(255)
declare @BackupFile varchar(300)
set @BackupPath = 'c:\temp\'
set @date = convert(varchar(10), getdate(), 112)
set @BackupFile = @BackupPath + @DatabaseName + '_' + @date + '.bak'
backup database @DatabaseName to disk=@BackupFile
GO
what i don't understand is:
1)what is the sp_msforeachdb doing
2)How does the name of each db get passed to the variable @databasename
sorry , i am new to this
thx
I am new to admin of sql. will be responsible for backups etc. I am trying out a script from a FAQ. and it requires me to run sp_foreachdb with a created stored proc:
CREATE procedure usp_BackupDatabase
@DatabaseName varchar(100)
as
declare @date varchar(10)
declare @BackupPath varchar(255)
declare @BackupFile varchar(300)
set @BackupPath = 'c:\temp\'
set @date = convert(varchar(10), getdate(), 112)
set @BackupFile = @BackupPath + @DatabaseName + '_' + @date + '.bak'
backup database @DatabaseName to disk=@BackupFile
GO
what i don't understand is:
1)what is the sp_msforeachdb doing
2)How does the name of each db get passed to the variable @databasename
sorry , i am new to this
thx