SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Permission issue or query issue


Permission issue or query issue

Author
Message
saidapurs
saidapurs
Old Hand
Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)

Group: General Forum Members
Points: 337 Visits: 414
Hi friends,
I have small doubt in below query. This query is use for zip the file and when i use thought command prompt its working 100% but when i use that query in SQL analyze getting error. some one advice me issue with security. Will pls advice me how i get output of below query..

DECLARE @MyFileName varchar(50), @COMMAND VARCHAR(100)
SELECT @MyFileName = (SELECT 'C:\DBBACKUP\Weekly_Full_Backup\store\' + convert(varchar(50),GetDate(),112) + '.bak')
-- BACKUP
BACKUP DATABASE store TO DISK = @MyFileName
-- COMPAC ZIP
SET @COMMAND = 'C:\7-Zip\7z.exe A ' + @MyFileName + '.ZIP ' + @MyFileName
EXEC XP_CMDSHELL @COMMAND


Errors are:-
1. C:\DBBACKUP\Weekly_Full_Back: WARNING: The system cannot find
the file specified.
2. Creating archive C:\DBBACKUP\Weekly_Full_Backup\store
\20120910.bak.ZIP
3. WARNINGS for files
4. C:\DBBACKUP\Weekly_Full_Back : The system cannot find the file
specified.
5. WARNING: Cannot find 1 file

NOTE :- Destination path is correct ..

Thanks in advance...

Satish
saidapurs
saidapurs
Old Hand
Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)

Group: General Forum Members
Points: 337 Visits: 414
Hi Friends,
I am getting output of above query when i change the path like

DECLARE @MyFileName varchar(50), @COMMAND VARCHAR(100)

SELECT @MyFileName = (SELECT 'C:\DBBACKUP\Full\Store\' + convert(varchar(50),GetDate(),112) + '.bak')

-- BACKUP
BACKUP DATABASE store TO DISK = @MyFileName
-- COMPAC ZIP
SET @COMMAND = 'C:\7-Zip\7z.exe A ' + @MyFileName + '.ZIP ' + @MyFileName
EXEC XP_CMDSHELL @COMMAND


in last query path was long now i reduce the path. Please advice me if i want to use longer path what shall i change...

Thanks
Satish
Sean Pearce
Sean Pearce
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1852 Visits: 3432
Increase the size of your variables to use a longer path

DECLARE @MyFileName varchar(255), @COMMAND VARCHAR(255)





The SQL Guy @ blogspot

@SeanPearceSQL

About Me
saidapurs
saidapurs
Old Hand
Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)

Group: General Forum Members
Points: 337 Visits: 414
Thanks Arto,
I change it into NVARCHAR(1000), then its working..

Thanks
Satish
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search