DECLARE @alenzi varchar(8000); -- Not varchar(max)
SELECT @alenzi = 'bcp "SELECT * FROM [DATABASE_NAME].[dbo].[TestingBCP]" queryout "C:\TestingBCP.txt" -t, -c -T';
EXEC master..xp_cmdshell @alenzi ;
Using BCP with queryout
Johnathan Simpson
586
Reputation points
ms sql server - bcp question. I've got this code
Select @sql = 'bcp "Select * FROM [dbo].[TestingBCP] queryout'
exec master..xp_cmdshell @sql
but I get this error
Msg 214, Level 16, State 201, Procedure xp_cmdshell, Line 1 [Batch Start Line 0]
Procedure expects parameter 'command_string' of type 'varchar'.