Question : string cuts of on varchar

when i run the following, the output is limited to 22 chars. I get the output of "Tracker_Aug 23 2010  7"; why is that?

declare @mystring varchar(100)
set @mystring   = cast (getdate() as varchar(100))
set @mystring =  'C:\Tracker_'+@holddate+'.bak'
BACKUP DATABASE Tracker TO DISK=  @mystring

Answer : string cuts of on varchar

In your own code, you never declare or set a value for @holddate.

Are you sure you have declared BOTH variables as varchar(100)  ?

To help see what is going on, remove the BACKUP command for a while, and replace it with
SELECT @mystring

THen once you know what is in the string, you can test the Backup command. My guess is that it does not like the spaces and/or special characters in your date format.
Random Solutions  
 
programming4us programming4us