Home > Archive > microsoft.public.sqlserver.server > November 2002 > Backup Database To Disk and device name





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Backup Database To Disk and device name
Scott Brookhart

2002-11-11, 10:24 am

I want to create a backup job that backs up a database and generates a
device name that includes the database name and a datetime stamp. How is
this done in a T-SQL Command in a SQL Job?
This is the current SQL Job Command I have
BACKUP DATABASE [IDB] TO DISK = N'D:\SQLBackups\IDB\IDBbak.bak' WITH
NOINIT , NOUNLOAD , NAME = N'IDB backup', NOSKIP , STATS = 10, NOFORMAT

Can the To Disk=N'D:\SQLBackups\IDB\IDB part be set to create a variable
device name?

Thanks,

--
Scott Brookhart
slbrook@hotmail.com


Wayne Snyder

2002-11-11, 12:23 pm

YOu can do this

declare @filename nvarchar(128)
select @filename = N'D:\SQLBackups\IDB\IDBbak.bak'
BACKUP DATABASE [IDB] TO DISK = @filename WITH
NOINIT , NOUNLOAD , NAME = N'IDB backup', NOSKIP , STATS = 10, NOFORMAT



--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)

I support the Professional Association of SQL Server (PASS) and it community
of SQL Server professionals.
www.sqlpass.org


"Scott Brookhart" <slbrook@hotmail.com> wrote in message
news:eXTfvnZiCHA.1756@tkmsftngp12...
> I want to create a backup job that backs up a database and generates a
> device name that includes the database name and a datetime stamp. How is
> this done in a T-SQL Command in a SQL Job?
> This is the current SQL Job Command I have
> BACKUP DATABASE [IDB] TO DISK = N'D:\SQLBackups\IDB\IDBbak.bak' WITH
> NOINIT , NOUNLOAD , NAME = N'IDB backup', NOSKIP , STATS = 10,

NOFORMAT
>
> Can the To Disk=N'D:\SQLBackups\IDB\IDB part be set to create a variable
> device name?
>
> Thanks,
>
> --
> Scott Brookhart
> slbrook@hotmail.com
>
>



Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net