BCP not extractin to csv

Hello,
I have this exact SQL that I am trying to execute in  Sql server management studio but tis not creating a csv extract at all…please see the attachments pic…no file is getting created….pleas help with this BCP thing

Thank you
declare @s varchar(30)
select @s = 'bcp ' +
     ' "SELECT * FROM [toyDB]..[a_toyTable] " ' +
     'queryout "C:\Test1\test.CSV" ' +
     '-T -c ' +
     '-S '
  exec master..xp_cmdshell @s 

Open in new window

error-null-result-no-csv.jpg
RayneAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RayneAuthor Commented:
I tried the BCP another way...see pics II....still getting error....this is frustrating...
bcp-type-2-error.jpg
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Two things:

1.

The xp_cmdshell it's disabled by default. Did you enable it?

2.

localhost isn't a recognized server or instance name for SQL Server. You may want to replace it by servername or servername\instancename if it's a named instance.
0
RayneAuthor Commented:
Hello Victor,
Thank you replying...
How do i activate the cmdshell?
Also, where can find the named instance within  [my computer]? I know the server name if that whats you meant?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
You can check if the xp_cmdshell is enabled my running the following code:
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'xp_cmdshell'
GO
sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO

Open in new window

If the returned column has an 1 then it's enabled. Zero is disabled.

For the instance name you can check in the SQL Server Configuration Manager but if you only have a SQL Server instance and if you used the default values then the server name should be used.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RayneAuthor Commented:
sorry was out of state for a while
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.