Hi
Strange, on my workstation it works fine
create table ww
(
col1 int,
col2 varchar(50),
col3 varchar (50)
)
insert into ww values (47,'ReadyShip','(503)888-999')
insert into ww values (48,'MyShipper','(503)1212-454')
insert into ww values (49,'ReadyShip','(45)888-999')
insert into ww values (50,'MyShipper','(545)1212-454')
---Prompt command
bcp northwind.dbo.ww out d:\test1.txt -c -t, -SSERVER -Usa -P.....
exec master..xp_cmdshell 'BCP northwind..ww out
d:\test1.txt -c -C850 -Sserver -Usa -P....'
[quoted text, click to view] "Sri" <Sri@discussions.microsoft.com> wrote in message
news:B96D1F64-5684-443B-B114-80721DED824F@microsoft.com...
> Hi Uri,
> Thanks for your solution. But when I execute the statement in query
analyser,
> I am getting the following error.
>
> Server: Msg 170, Level 15, State 1, Line 2
> Line 2: Incorrect syntax near '"' '.
>
> Please help me.
>
> "Uri Dimant" wrote:
>
> > Sri
> > EXEC master..xp_execresultset N'SELECT
> > ''EXEC master..xp_cmdshell ''''BCP "SELECT * FROM Northwind..Orders "
> > queryout "C:\Temp\1.csv" -w -t"|" -T -S"''+@@servername+''"'''' ''
> > ',N'Northwind'
> >
> >
> >
> >
> > "Sri" <Sri@discussions.microsoft.com> wrote in message
> > news:B6439937-8D48-4F55-9D14-8416DE437CF4@microsoft.com...
> > > How do you save the output of a query/stored procedure to a text file?
> > > Thanks in advance
> >
> >
> >