Click here to Skip to main content
15,893,161 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Server 2000 connectivity issue [fixed] Pin
Corporal Agarn25-Jan-10 4:21
professionalCorporal Agarn25-Jan-10 4:21 
QuestionTITLE: The Secret $5680 in 24 Hour Strategy Pin
BILAL 200923-Jan-10 3:06
BILAL 200923-Jan-10 3:06 
Questionalter table Pin
FEMDEV22-Jan-10 3:56
FEMDEV22-Jan-10 3:56 
AnswerRe: alter table Pin
Bassam Saoud22-Jan-10 5:01
Bassam Saoud22-Jan-10 5:01 
GeneralRe: alter table Pin
FEMDEV22-Jan-10 5:42
FEMDEV22-Jan-10 5:42 
GeneralRe: alter table Pin
loyal ginger22-Jan-10 6:28
loyal ginger22-Jan-10 6:28 
GeneralRe: alter table Pin
FEMDEV25-Jan-10 2:06
FEMDEV25-Jan-10 2:06 
QuestionBACKUP DATABASE command Pin
ednrg22-Jan-10 2:18
ednrg22-Jan-10 2:18 
I'm trying to do a SQL Server script that will backup a database to a file.

DECLARE @Filename NVARCHAR(MAX)

SELECT @Filename = N'\\{mymachinenameonnetwork}\SQL Backups\mydb_backup_' + convert(varchar, getdate(), 102) + '_' + replace(convert(varchar, getdate(), 8),':','')  

SELECT @Filename

BACKUP DATABASE [mydb] TO  DISK = @Filename WITH NOFORMAT, NOINIT,  NAME = N'mydb-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10
GO


This will not produce a backup file. But, if I create a variable of the entire statement and run it via sp_executesql, it works perfectly.
SELECT @Cmd = 'BACKUP DATABASE [mydb] TO  DISK = ''' + @Filename + ''' WITH NOFORMAT, NOINIT, NAME = N''mydb-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 10'

exec sp_executesql @stmt=@Cmd


There must be some reason that I'm not seeing. Can anyone shed some light on this problem?

Thanks,
Ed
AnswerRe: BACKUP DATABASE command Pin
Covean22-Jan-10 3:38
Covean22-Jan-10 3:38 
GeneralRe: BACKUP DATABASE command Pin
ednrg22-Jan-10 9:00
ednrg22-Jan-10 9:00 
QuestionMySQL Pin
Muammar©22-Jan-10 0:50
Muammar©22-Jan-10 0:50 
AnswerRe: MySQL Pin
Muammar©22-Jan-10 3:39
Muammar©22-Jan-10 3:39 
AnswerRe: MySQL Pin
loyal ginger22-Jan-10 4:24
loyal ginger22-Jan-10 4:24 
GeneralRe: MySQL Pin
Muammar©22-Jan-10 5:41
Muammar©22-Jan-10 5:41 
AnswerRe: MySQL Pin
dybs22-Jan-10 20:08
dybs22-Jan-10 20:08 
GeneralRe: MySQL Pin
Muammar©22-Jan-10 20:45
Muammar©22-Jan-10 20:45 
GeneralRe: MySQL Pin
loyal ginger25-Jan-10 5:02
loyal ginger25-Jan-10 5:02 
GeneralRe: MySQL Pin
dybs25-Jan-10 15:11
dybs25-Jan-10 15:11 
GeneralRe: MySQL Pin
loyal ginger25-Jan-10 16:58
loyal ginger25-Jan-10 16:58 
QuestionParamaterised access queries Pin
Russell Jones21-Jan-10 23:31
Russell Jones21-Jan-10 23:31 
AnswerRe: Paramaterised access queries Pin
Eddy Vluggen21-Jan-10 23:58
professionalEddy Vluggen21-Jan-10 23:58 
QuestionNeed some advices on SQL INTERSECT Function Pin
James Shao21-Jan-10 21:19
James Shao21-Jan-10 21:19 
AnswerRe: Need some advices on SQL INTERSECT Function Pin
Dimitri Witkowski24-Jan-10 6:04
Dimitri Witkowski24-Jan-10 6:04 
AnswerRe: Need some advices on SQL INTERSECT Function Pin
Mycroft Holmes24-Jan-10 10:44
professionalMycroft Holmes24-Jan-10 10:44 
GeneralRe: Need some advices on SQL INTERSECT Function Pin
James Shao25-Jan-10 12:06
James Shao25-Jan-10 12:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.