declare @cmd nvarchar(255)
SET @cmd = 'bcp "select * from Testdb.dbo.mytable WHERE nr LIKE ''%102065336''' + '" queryout C:\temp\sample.xml -c -t, -S' + @@servername + ' -T'
exec xp_cmdshell @cmd
That Code returns a correct .xml file with correct format, but when i use this @cmd so with "=" instead of "LIKE" the xml file looks broken(only cryptic chars in it) :
SET @cmd = 'bcp "select * from Testdb.dbo.mytable WHERE nr = ''102065336''' + '" queryout C:\temp\sample.xml -c -t, -S' + @@servername + ' -T'
So How is this possible? The queries return the same data if i execute the sql statement...