I'm using the following query to write the data in a external file:
declare @sql varchar(8000);
select @sql = 'bcp tempdb.##hmscript out
F:\HMS\test.txt -c -t, -T -S GIT2B-01\MON'
select @sql
exec master..xp_cmdshell @sql;
When testing the bcp in cmd window I'm getting the following error:
SQLState = 37000, NativeError = 11525 Error = [Microsoft][SQL Server Native Client 11.0][SQL Server]The metadata could not be determined because statement 'select * from ##hmscript' uses a temp table.
Somebody has a solution for this?
Thanks in advance,
David