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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 concatenate variables

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 help

use master
go
DECLARE @FinalStatus int,
@ErrorStatus int,
@i INT,
@FolderPath char(180),
@FilePath char(180),
@Totalpath char(360)

SET @FinalStatus=0
SET @ErrorStatus=99
Set @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 together



BACKUP 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=@ErrorStatus
END

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-03 : 15:23:46
Run this to see what @totalpath equals:

PRINT @totalpath

Post the results here.

Alternatively, you could just use these (which I wrote):
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx

Tara Kizer
aka tduggan
Go to Top of Page

morphias0
Starting Member

20 Posts

Posted - 2006-02-03 : 15:27:10
This is what comes up

\\mis022000\test\
Go to Top of Page

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.
Go to Top of Page

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 Kizer
aka tduggan
Go to Top of Page

morphias0
Starting Member

20 Posts

Posted - 2006-02-03 : 15:55:05
Problem Solved, That was the right solution

Thank you
Go to Top of Page
   

- Advertisement -