Questions tagged [xp-cmdshell]

an extended stored procedure provided by SQL Server, which launches a Windows command shell to run a specified command. Not for general questions about cmd.exe or batch scripting; not related to Windows XP.

The xp_cmdshell extended stored procedure runs the command string given and returns any output as rows of text. The documentation (for SQL Server 2012) can be found here.

For security reasons, xp_cmdshell is disabled by default in recent versions of SQL Server.

264 questions
0
votes
0 answers

Executing powershell from SQL xp_cmdshell

I have a powershell file that looks to a directory and locks the fields on each of the Word documents that are contained in that directory. I am executing this powershell file from a SQL stored procedure using xp_cmdshell. I have implemented this…
0
votes
0 answers

SQL Server bcp Import functionality not working properly

I have a ";" separated file to be imported in SQL Server. I am using bcp. I get no error but a display of bcp arguments. No data is imported. here is my code. any advise? Create table #T1 ( [Tracking Number] VARCHAR(200), [Reference…
user3376020
0
votes
0 answers

Powershell from SQL with xp_cmdshell?

I am trying to run a powershell command to return some data to a SQL table but I am having no luck getting it working. Specifically I want to pull a list of all the Users details in the User Profile service from SharePoint and then query LDAP…
user802599
  • 787
  • 2
  • 12
  • 35
0
votes
2 answers

How can I save SQL Server BCP queryout result into the local network share folder?

I want write query to run the BCP utility and save the query result into the network share folder. For that purpose I mapped another pc's share folder in my local network to my drive. That drive name is z. In my explorer it shows me the mapped…
0
votes
1 answer

Using BCP and xp_cmdshell with T-SQL inside SSMS. "The syntax of the command is incorrect"

So, I am playing around with BCP to get to know it better, and ran into an issue I am having trouble figuring out. I am getting an error, "The Syntax of the command is incorrect". I have tested the complete file path which is building correctly, and…
Jeff.Clark
  • 599
  • 1
  • 5
  • 27
0
votes
1 answer

Why can I not save my query result to csv file SQL Server?

I'm beginner in SQL Server, and want to save query result auto in csv file. This is the query: EXEC master..xp_cmdshell'bcp "SELECT [ID] ,[FirstName] ,[LastName] ,[StartYear] FROM [dbo].[Employees]" queryout "e:\text.txt" -c -T…
user3671271
  • 551
  • 2
  • 8
  • 21
0
votes
1 answer

xp_cmdshell semi-colon separation

I am using xp_cmdshell and i want the output to the text file to be semi-colon separated. I have tested the following: -- To allow advanced options to be changed. EXEC sp_configure 'show advanced options', 1; GO -- To update the currently configured…
PuchuKing33
  • 381
  • 3
  • 7
  • 19
0
votes
1 answer

SQL Server xp_cmdshell fail to export data

I want to export values from a column (TcpIpAddress) from a table called dbo.DimServere to a plain text (located in the server). I have sysadmin rights. -- To allow advanced options to be changed. EXEC sp_configure 'show advanced options',…
PuchuKing33
  • 381
  • 3
  • 7
  • 19
0
votes
1 answer

Calling dtsrun with xp_cmdshell from stored procedure - The Microsoft Jet database engine cannot open the file error

I'm trying to execute DTS package (let's call it 'MY_DTS') from within stored procedure. Without success. Here's my procedure's code: CREATE PROCEDURE [dbo].[RUN_DTS] @DTSName nvarchar(4000) AS DECLARE @Command AS nvarchar(4000) SET @Command…
browning0
  • 901
  • 2
  • 11
  • 21
0
votes
0 answers

Unable to run a C# .exe using sp_cmdshell stored procedure

I want to run a Selenium C# .exe using a SQL job. But its throwing an error The process could not be created for step 1 of job 0xF389F41117ABC54D9DDB8DF613345572 (reason: The parameter is incorrect). The step failed. Executed Command : EXEC…
0
votes
1 answer

How to create .csv file from SQL with xp_cmdshell on linux shared folder with samba?

So its kind of complicated I think, I've been searching all day for a solution. I have a SQL Server 2008 R2 and with xp_cmdshell I currently generate some .csv files in C:\ What I want to do now is generate them directly into a linux server in the…
Elgert
  • 470
  • 2
  • 5
  • 19
0
votes
1 answer

Calling GraphicsMagick command using T_SQL xp_cmdshell procedure

I have been trying to call a GraphicsMagick command through the T-SQL xp_cmdshell procedure, but I am getting errors with the same. The command I am trying to call is as below : gm convert "\dklyefxdb1\X\Backup\apple_raw.jpg" -scale 200x250…
0
votes
1 answer

xp_cmshell 'wlan show profile name="xxxx" key=clear'

xp_cmdshell 'netsh wlan show profile name="xxxx"' It gives me information about my Wifi network. But when I am trying to use the same command with "key=clear" xp_cmdshell 'netsh wlan show profile name="XXX" key=clear' I am getting back the same…
mr R
  • 997
  • 2
  • 12
  • 25
0
votes
1 answer

TSQL with cmdshell how I can catch exception?

I made this script to process batch .sql source files to define SP (as part of migration). It works fine but I can' catch any exception, when any source file is bad and given sp can not be created. I tried touse try/catch and looks like cmdshell…
Mario Trento
  • 513
  • 1
  • 4
  • 14
0
votes
1 answer

MS SQL 2000 - Parameters in DTSRUN using xp_cmdshell

I am running the following: master..xp_cmdshell 'dtsrun /S ricmssql02 /U admindw /P letmein /N "scott - debug"' but also send parameters. I am seeing the following to do that: /A global_parameter_name:typeid=value And also that the whole thing can…
Mark