I run this SQL code:
declare @sqlselect varchar(100), @cmd varchar(100)
set @sqlselect = '"select * from [sr05107].[armaninodw].[dbo].[vw_items]"'
set @cmd = 'bcp '+ @sqlselect + ' queryout "D:\PrecisionPoint\Customer_Credit_Limit_rpt.csv" -T'
EXEC master..XP_CMDSHELL @cmd
I get this error:
User name not provided, either use -U to provide the user name or use -T for Trusted Connection
Please help!
Tried adding -U and -P while removing the -T.
@cmd varchar(100)will be too short to hold full command line, try@cmd varchar(4000).As usual, it's good to PRINT your dynamic strings.