SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Too many arguments specified.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

latture
Starting Member

24 Posts

Posted - 02/06/2013 :  10:53:16  Show Profile  Reply with Quote
Hello, fairly new here.

I'm getting a 'Msg 8144, Level 16, State 201, Procedure xp_cmdshell, Line 1 Procedure or function xp_cmdshell has too many arguments specified' error message when I run the bcp process below. Can anyone tell me why?

exec master..xp_cmdshell 'BCP "DECLARE @colnames VARCHAR(max);SELECT @colnames = COALESCE(@colnames + ',', '') + column_name from RPIUser_input.dbo.INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=PartSiteTrans; select @colnames;" queryout c:\export\HeadersOnly.csv -c -T -SRQL', no_output

Edited by - latture on 02/06/2013 10:54:42

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/06/2013 :  11:07:00  Show Profile  Reply with Quote
try like

DECLARE @BCPCmd varchar(8000)

SET @BCPCmd='BCP "DECLARE @colnames VARCHAR(max);SELECT @colnames = COALESCE(@colnames + ',', '') + column_name from RPIUser_input.dbo.INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=PartSiteTrans; select @colnames;" queryout c:\export\HeadersOnly.csv -c -T -SRQL'

EXEC xp_cmdshell @BCPCmd,no_output



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

latture
Starting Member

24 Posts

Posted - 02/06/2013 :  11:41:12  Show Profile  Reply with Quote
Sweet, thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/06/2013 :  11:42:00  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000