Re: Oddity with backup

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 17:50:01 +0100

Julie,

Ahh, it is because colon, :, is not allowed in a file name, so Windows chops
off everything from the first colon and forwards.

-- 
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Julie" <anonymous@discussions.microsoft.com> wrote in message
news:339401c3fd4d$0073bd00$a401280a@phx.gbl...
> Thanks Tibor,
>
> I changed my code to the following, mainly to check your
> sugestion
>
> Declare @FileName as varchar(200)
> set @FileName = 'D:\Backup ' + ltrim(rtrim(cast(getdate()
> as varchar(50)))) + '.bak'
>
> BACKUP DATABASE TestDatabase
> TO DISK = @FileName
>
> And got exactly the same response.
>
> Thanks
> J
>
>
> >-----Original Message-----
> >I would start by declaring the @FileName variable as
> variable length
> >datatype. My guess is that you have some trailing spaces
> issue here...
> >
> >-- 
> >Tibor Karaszi, SQL Server MVP
> >Archive at:
> >http://groups.google.com/groups?
> oi=djq&as_ugroup=microsoft.public.sqlserver
> >
> >
> >"Julie" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:321c01c3fd46$c1e82360$a001280a@phx.gbl...
> >> Dear All
> >>
> >> I have the following code
> >>
> >> Declare @FileName as char(200)
> >> set @FileName = 'D:\Backup ' + cast(getdate() as varchar
> >> (50)) + '.bak'
> >> BACKUP DATABASE TestDatabase
> >> TO DISK = @FileName
> >>
> >> It should create a new backup using the date time.
> >>
> >> However what actually happens is
> >>
> >> 1) Only one backup is created, no matter how many times
> >> its run
> >>
> >> 2) On disk the filename says 'Backup Feb 27 2004 3'
> >> without the rest of the date.
> >>
> >> 3) On Windows explorer it reports the file size as 0
> >> bytes, even though Query Analyser reports success.
> >>
> >> Any pointers ?
> >>
> >> J
> >
> >
> >.
> >