I debug a stored procedure (SQL Server 2005) and I need to find out some values in a datatable.
The procedure is run by an event of the application and I watch just
bcp out
exports tables.
To export a query use queryout
instead - you'll need to wrap your query in "double quotes"
set @logtext = '"select name, type from master.dbo.spt_values where number=6"'
--set @logtext = 'master.dbo.spt_values'
SET @cmd = 'bcp ' + @logtext + ' queryout "c:\spt_values.dat" -U uId -P uPass -c'
EXEC master..XP_CMDSHELL @cmd
http://msdn.microsoft.com/en-us/library/ms162802.aspx