473,413 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

sql exec copy file failed

ddtpmyra
333 100+
I need help to make this procedure copying file works for me.

The error is
Msg 50000, Level 16, State 1, Procedure sp_copyfile, Line 23
File copy failed

Expand|Select|Wrap|Line Numbers
  1. USE [NGProd]
  2. GO
  3. /****** Object:  StoredProcedure [dbo].[copyfile]    Script Date: 12/20/2011 10:37:44 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8.  
  9. ALTER PROCEDURE [dbo].[copyfile] @sourcefilepath sysname, @targetfilepath sysname=NULL
  10. AS
  11.  
  12. SET NOCOUNT ON
  13. IF (@sourcefilepath='/?') OR (@targetfilepath IS NULL) GOTO Help
  14.  
  15. DECLARE @cmdstr varchar(8000)
  16.  
  17. CREATE TABLE #cmd_result (output varchar(8000))
  18.  
  19. EXEC master..xp_sprintf @cmdstr OUTPUT, 'copy %s %s',@sourcefilepath, @targetfilepath
  20.  
  21. INSERT #cmd_result
  22. EXEC master..xp_cmdshell @cmdstr
  23.  
  24. SELECT * FROM #cmd_result
  25.  
  26. IF EXISTS(SELECT * FROM #cmd_result WHERE output like '%file(s) copied%') BEGIN
  27.     SET @cmdstr='The file copy operation "'+@cmdstr+'" was successful (at least one file was copied)'
  28.     PRINT @cmdstr
  29.     EXEC master..xp_logevent 60000, @cmdstr, 'INFORMATIONAL'
  30. END ELSE RAISERROR('File copy failed',16,1)
  31.  
  32. DROP TABLE #cmd_result 
  33. RETURN 0
  34.  
  35. Help:
  36.  
  37. print 'Error'
  38.  
Dec 20 '11 #1
0 1483

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jan Plastenjak | last post by:
Error Type: ADODB.Stream (0x800A0BBC) Write to file failed. Why? :(
1
by: vireemani | last post by:
Hi all, I have a form with some server controls on it. I changed text box ID's and compiled the solution. I got an error message saying type or namespace name "txtEmrgcyContactName" could not be...
0
by: Grey | last post by:
I have a ASP.NET web application which is required to copy file from windows server to Novell Netware server. I have used impersonation to connect to Netware server. The application works fine when...
5
by: ALthePal | last post by:
Hi, I am receiving this message when I start up VS.NET 1.0 on WinXP, File Failed to load in WEb Form designer. Please correct the following error, then load it again: Exception from...
5
by: Standist | last post by:
I want install software on PC in my local network. First I want copy file to the PC through default share like c$ or d$ on the PC. Then install the software through wmi. I have the administrator...
0
by: whgriffin | last post by:
I'm using Aspose.Excel to export a recordset to excel. I have code that has work 100 times before, but just ran into an issue. If I have a button and run the Sub Report() from the onPostBack() in...
9
rizwan6feb
by: rizwan6feb | last post by:
Hello everybody. I need help on how to use copy function to copy file from one computer to another ( or any other way i can copy the file). The computers are on a local network.
0
by: Andy B | last post by:
I added a LINQ classes (dbml) file to my web application project and drug a sql server database table from the server explorer onto the o/r designer. I saved and closed the designer after that. I...
2
by: foss | last post by:
hi all, I am not able to copy file from a directory in the server to another directory. Here, the source is outside the web root directory and the destination is inside the web root directory. ...
5
by: phpnewbie26 | last post by:
I've been having trouble trying to open a file. It outputs fopen(/projects/CCPROT/ts_classes) : failed to open stream: No such file or directory in /mnt/raid/www/intra/admin/ts2/test2.php on line 72...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.