Quantcast
Channel: Questions in topic: "xp_cmdshell"
Viewing all 40 articles
Browse latest View live

Robocopy ERROR : No Destination Directory Specified.

$
0
0
Hi , I am trying to copy the file using Robocopy in SQL. It give me following message:- NULL ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows :: Version XP010 ------------------------------------------------------------------------------- NULL Started : Fri Oct 08 16:45:59 2010 NULL Source : \\hsbc-bsc1\ggg Dest - NULL Files : *.* Options : *.* /COPY:DAT /R:1000000 /W:30 NULL ------------------------------------------------------------------------------ NULL ERROR : No Destination Directory Specified. NULL Simple Usage :: ROBOCOPY source destination /MIR NULL source :: Source Directory (drive:\path or \\server\share\path). destination :: Destination Dir (drive:\path or \\server\share\path). /MIR :: Mirror a complete directory tree. NULL For more usage information run ROBOCOPY /? or read Robocopy.Doc. NULL NOTE: Read "True Replication" in Robocopy.Doc prior to first use of /MIR ! **** /MIR can DELETE files as well as copy them ! NULL But when i run using XP_cmdshell it work fine. Actullly it is not identifying my Destination folder where i want to copy . Pls help. The feild Dest - is empty.

Using xp_cmdshell to view the time of the latest folder created

$
0
0
Hi, There is a folder in the drive. Using xp_cmdshell I want to view the timing of the latest folder created. How to know the timing of the folder created? This Timing I have to assign to a variable.

How do I start a windows app (with a gui) from a stored procedure on SQL 2008

$
0
0
Hi I am writing a small customisation to an SQL based accounting system. When a new sales order is created by a custom stored procedure, I want send a copy of the order via email to the dispatch dept. **Plan A - xp_cmdshell** The accounting package has a report writer that can receive the required parameters to produce a pdf file, but it does have a gui, though there is no requirement for the user to respond to anything, but since it has a windows gui implemented I cannot use xp_cmdshell to run the report writer exe. **Plan B - SSIS package** I figured I would try using SSIS instead, this seems to work fine, passing the parameter (the SEQNO of the order I want to print among other things), however I still can't find a way to run this from within the stored procedure which creates the order. Again I come up against xp_cmdshell and the gui limitation, since the dtexec utility still gets called using xp_cmdshell and so the gui based exe fails to run properly. **Plan C - SSIS package run using SQL Server Agent** My next idea was to create a job in SQL Server Agent to run the SSIS package - but I can't figure out how to pass the parameters back to the package - remember I need to tell the package which order to generate the report and email for. I am open to ideas and any pointers here! Thanks a heap, Andrew PS thanks to all of you for the useful and interesting articles and blogs.

sql 2005 send MSG using xp_cmdshell to windows 2007 client

$
0
0
I try command from QA exec xp_cmdshell 'MSG * /Server:WSxxx "test"' I got error * does not exist or is disconnected Client who send message SQL 2005 on windows 2003 client who receive message is on windows 2007 when I trying same command from CMD message was succesfull sended.

Moving and renaming files using xp_cmdshell

$
0
0
I need to move and rename a file but for reasons I'm not going into can't use SSIS or DTS. I'm trying to use xp_cmdshell and getting the message "The syntax of the command is incorrect". I'm using examples I've found on line and am confused as to what I've done wrong. The rename should add the date onto the filename, for example EandWTest.txt should be moved to an archive folder and renamed EandWTest_0110523_16_07.txt. This is the code I've found and am trying to fit my needs, I'm not actually using the variables to stipulate the filename and path but will do that when I've got the basic code working: DECLARE @TodayDate as varchar(40), @TodayHour as varchar(40), @TodayMinu as varchar(40), @NewFileName as varchar(100), @cmdstr as varchar(128), @cmd VARCHAR(255), @sFileName AS VARCHAR(255), @sPath AS VARCHAR(255) SET @sFileName = 'EandWTest.txt' SET @sPath = 'C:\Auto Import\Auto Import\' SELECT @TodayDate = CONVERT(varchar(10), GETDATE(), 112) SELECT @TodayHour = DATEPART(hh,GETDATE()) SELECT @TodayMinu = DATEPART(mi,GETDATE()) SELECT @NewFileName = @sFileName + '_' + @TodayDate + '_' + @TodayHour + '_' + @TodayMinu + '.txt' print @NewFileName set @cmdstr='MOVE /Y C:\Auto Import\Auto Import\EandWTest.txt C:\Auto Import\Auto Import\Archive\' + @NewFileName print @cmdstr EXEC master..xp_cmdshell @cmdstr Many thanks.

Surface Area Configuration Manager

$
0
0
Hi, I'm using SQL Server 2008 for a reporting system and wanted to enable the xp_cmdshell through the Surface Area Configuration manager but was unable to find it. I have enabled it through sp_configure but was wondering if the "Surface Area Configuration Manager" no longer exists on SQL Server 2008 and onwards? Additionally, even though I have enabled xp_cmdshell (which I understand is a security risk), I still get an error that its not enabled when I run a DTSX package which basically grabs a file from an FTP using xp_cmdshell. Any advice would be helpful. Thanks, S

Zip files using XP_cmdshell

$
0
0
Can anyone please advise me on the command to zip files using xp_cmdshell. I need to zip files from within an SSIS package and thought this may be the easiest route. Any other ideas greatfully received Many thanks.

xp_cmdshell format returned

$
0
0
Hi, I have the following problem , on some servers xp_cmdshell returns the date in this format output Volume in drive D is New Volume Volume Serial Number is A834-F9EE NULL Directory of d:\sqlinstalls\cu6 NULL 03/23/2011 01:51 PM . 03/23/2011 01:51 PM .. 02/04/2011 01:56 AM 8,119,808 sqlncli.msi 02/04/2011 02:38 AM 292,314,464 SQLServer2008R2-KB2489376-x64.exe 2 File(s) 300,434,272 bytes 2 Dir(s) 6,529,056,768 bytes free NULL and on others like this Volume in drive C is OS Volume Serial Number is 46FC-9B0C NULL Directory of c:\ NULL 20/04/2011 16:23 485,098 cybdefauth_i.log 25/04/2011 02:35 21,259 CybDefInstallInfo.log 20/04/2011 16:22 121 CybDefWebInstaller.log 24/08/2010 16:43 d7f152059018fbb2d699e6832fab2157 06/01/2010 12:28 dell 21/06/2011 19:54 Windows 4 File(s) 1,411,182 bytes 17 Dir(s) 77,513,871,360 bytes free NULL the problem is with the AM/PM, I assume it is a locale setting, Does anyone know what I can check to see the sql server regional setting ? is it the collation ? this is messing up a proc I am working on thanks

How to use xp_cmdshell for NET SEND

$
0
0
Hi, Can anybody tell me how to use xp_cmdshell for NET SEND , I tried but im getting error msg The option /ENVENTURE.LOCAL:SQL_USERS is unknown. NULL The syntax of this command is: NULL NULL NET SEND {name | * | /DOMAIN[:name] | /USERS} message NULL NULL More help is available by typing NET HELPMSG 3506. NULL NULL

Rename scripted db objects

$
0
0
How can I rename all scripted object files in a folder, to replace 'dbo.' with the object type (Table, view..etc) and remove the appended object type (.Table, .view ..etc) from the file name As an example: I have 'C:\Tables\dbo.User.Table.SQL' I want to change that to 'C:\Tables\Table User.SQL' I tried using xp_cmdshell with rename, but get an 'Access is denied' message. My Id has sysadmin access on the server and full access to the file. TIA

How can I export one column as a separate text file for each row?

$
0
0
Let's say I have a table with this info in SQL Server 2008 (2 columns): DocNumber, Text 0000001, this is the text for doc 1 0000002, this is the text for doc 2 What I need to do, is create text files for each row named by the DocNumber column. So something like select [Text] from table and then send that to [DocNumber].txt, then loop through the rows. I'm guessing I'll need to use xp_cmdshell. I need to end up with 000001.txt and 000002.txt. Any suggestions or resources that might have something similar that I can play around with? It just needs to be a SQL script. thanks, Mike

unable to run powershell script from xp_cmdshell

$
0
0
Hi I am very new to powershell but when I run the below command in power shell it executes successfully and gives the required output but when I run the same command in xp_cmdshell it is not giving any output. declare @sql varchar(2000) set @sql= 'powershell.exe -c "$strComputer = Get-Content C:\Users\admin\Desktop\servername.txt foreach ( $computer in $strComputer) { Get-WmiObject -Class win32_service -computername $computer | where {$_.name -like ''MSSQLServer'' -OR $_.name -like ''MSSQL$*'' -OR $_.name -like ''SQLAgent$*'' -OR $_.name -like ''SQLSERVERAGENT'' } | select-object Name,state,systemname,startmode,startname}"' print @sql EXEC xp_cmdshell @sql Can somebody help me on this ? I am stuck with this part. Thanks On advance

Running xp_cmdshell as Administrator

$
0
0
Does anyone know if it is possible to invoke xp_cmdshell as Administrator? I am working on trying to start the SQLSERVERAGENT service from TSQL but it fails with 'access denied' - from TSQL and from cmd. The only way I can get it to succeed is to run cmd as Administrator and then `SC START SQLSERVERAGENT` works. I dont want to alter UAC to get around this problem.

XP_CMDSHELL Proxy Failover Cluster

$
0
0
I have 2 instances setup in an active active failover cluster. I am having some trouble setting up a proxy account for xp_cmdshell. When I set up xp_cmdshell proxy for a user lets call it "testuser" on instance 1 all works fine. The issue I am seeing is when I failover instance 1 to instance 2 then the "testuser" can no longer execute xp_cmdshell commands. Is there something specific I need to do to have this work in a failover situation? The credential identity Domain is pointing to the computer name of instance 1. I get this error message: Msg 15153, Level 16, State 1, Procedure xp_cmdshell, Line 1 The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the '##xp_cmdshell_proxy_account##' credential exists and contains valid information.

Using xp_cmdshell to view the time of the latest folder created

$
0
0
Hi, There is a folder in the drive. Using xp_cmdshell I want to view the timing of the latest folder created. How to know the timing of the folder created? This Timing I have to assign to a variable.

How do I start a windows app (with a gui) from a stored procedure on SQL 2008

$
0
0
Hi I am writing a small customisation to an SQL based accounting system. When a new sales order is created by a custom stored procedure, I want send a copy of the order via email to the dispatch dept. **Plan A - xp_cmdshell** The accounting package has a report writer that can receive the required parameters to produce a pdf file, but it does have a gui, though there is no requirement for the user to respond to anything, but since it has a windows gui implemented I cannot use xp_cmdshell to run the report writer exe. **Plan B - SSIS package** I figured I would try using SSIS instead, this seems to work fine, passing the parameter (the SEQNO of the order I want to print among other things), however I still can't find a way to run this from within the stored procedure which creates the order. Again I come up against xp_cmdshell and the gui limitation, since the dtexec utility still gets called using xp_cmdshell and so the gui based exe fails to run properly. **Plan C - SSIS package run using SQL Server Agent** My next idea was to create a job in SQL Server Agent to run the SSIS package - but I can't figure out how to pass the parameters back to the package - remember I need to tell the package which order to generate the report and email for. I am open to ideas and any pointers here! Thanks a heap, Andrew PS thanks to all of you for the useful and interesting articles and blogs.

sql 2005 send MSG using xp_cmdshell to windows 2007 client

$
0
0
I try command from QA exec xp_cmdshell 'MSG * /Server:WSxxx "test"' I got error * does not exist or is disconnected Client who send message SQL 2005 on windows 2003 client who receive message is on windows 2007 when I trying same command from CMD message was succesfull sended.

Moving and renaming files using xp_cmdshell

$
0
0
I need to move and rename a file but for reasons I'm not going into can't use SSIS or DTS. I'm trying to use xp_cmdshell and getting the message "The syntax of the command is incorrect". I'm using examples I've found on line and am confused as to what I've done wrong. The rename should add the date onto the filename, for example EandWTest.txt should be moved to an archive folder and renamed EandWTest_0110523_16_07.txt. This is the code I've found and am trying to fit my needs, I'm not actually using the variables to stipulate the filename and path but will do that when I've got the basic code working: DECLARE @TodayDate as varchar(40), @TodayHour as varchar(40), @TodayMinu as varchar(40), @NewFileName as varchar(100), @cmdstr as varchar(128), @cmd VARCHAR(255), @sFileName AS VARCHAR(255), @sPath AS VARCHAR(255) SET @sFileName = 'EandWTest.txt' SET @sPath = 'C:\Auto Import\Auto Import\' SELECT @TodayDate = CONVERT(varchar(10), GETDATE(), 112) SELECT @TodayHour = DATEPART(hh,GETDATE()) SELECT @TodayMinu = DATEPART(mi,GETDATE()) SELECT @NewFileName = @sFileName + '_' + @TodayDate + '_' + @TodayHour + '_' + @TodayMinu + '.txt' print @NewFileName set @cmdstr='MOVE /Y C:\Auto Import\Auto Import\EandWTest.txt C:\Auto Import\Auto Import\Archive\' + @NewFileName print @cmdstr EXEC master..xp_cmdshell @cmdstr Many thanks.

Surface Area Configuration Manager

$
0
0
Hi, I'm using SQL Server 2008 for a reporting system and wanted to enable the xp_cmdshell through the Surface Area Configuration manager but was unable to find it. I have enabled it through sp_configure but was wondering if the "Surface Area Configuration Manager" no longer exists on SQL Server 2008 and onwards? Additionally, even though I have enabled xp_cmdshell (which I understand is a security risk), I still get an error that its not enabled when I run a DTSX package which basically grabs a file from an FTP using xp_cmdshell. Any advice would be helpful. Thanks, S

Zip files using XP_cmdshell

$
0
0
Can anyone please advise me on the command to zip files using xp_cmdshell. I need to zip files from within an SSIS package and thought this may be the easiest route. Any other ideas greatfully received Many thanks.
Viewing all 40 articles
Browse latest View live