Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
morphias0
Starting Member
20 Posts |
Posted - 2006-02-03 : 15:19:41
|
I cant seem to get these two variables to join. Its pretty simple code, and im new at this but i just want to be able to back up my db with a script. Heres what I have, and thanks for the helpuse mastergoDECLARE @FinalStatus int, @ErrorStatus int, @i INT, @FolderPath char(180), @FilePath char(180), @Totalpath char(360) SET @FinalStatus=0SET @ErrorStatus=99Set @FolderPath= '\\mis022000\test\'set @FilePath= 'test.bak'set @totalpath = @FolderPath + @FilePath --At this point it only reads the first variable @folderpath, but it--never joins them togetherBACKUP DATABASE [Wise Services Database] TO DISK = @totalpath WITH INIT , NOUNLOAD , NAME = N'CA Services Database backup', NOSKIP , STATS = 10, NOFORMAT IF @@ERROR <> 0 BEGIN SET @FinalStatus=@ErrorStatusEND |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
morphias0
Starting Member
20 Posts |
Posted - 2006-02-03 : 15:27:10
|
This is what comes up\\mis022000\test\ |
|
|
morphias0
Starting Member
20 Posts |
Posted - 2006-02-03 : 15:36:48
|
I see in your script that you have the path set to :-- Build the .BAK path and file name SELECT @filename = @Path + @DBName + '\' + @DBName + '_' + @Now + '.BAK'so i tried to use select instead of set and that didnt work either. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-03 : 15:49:59
|
I think I know what the problem is now. You are using char instead of varchar. So even though you are setting @FolderPath = '\\mis022000\test\', it's actually getting set to '\\mis022000\test\xxxxxxxxxxxxx where x represents spaces to fill the variable to 180 characters. Use varchar for your variables instead.Tara Kizeraka tduggan |
|
|
morphias0
Starting Member
20 Posts |
Posted - 2006-02-03 : 15:55:05
|
Problem Solved, That was the right solutionThank you |
|
|
|
|
|
|
|