C
C#3y ago
FR

❔ SQL Server | How to format column using BCP?

#ask #bcp # sql server hi, so.... im using bcp to export data to excel and the query like this
select
date_create
, code
into ##temp_table_a
from table b
join ....
where ...

set @sql='exec master..xp_cmdshell ''bcp "select * from '+'tempdb'+'..'+'##temp_table_a'+'" queryout "c:/xxx/xxx.xls" -c -T '''
exec(@sql)
select
date_create
, code
into ##temp_table_a
from table b
join ....
where ...

set @sql='exec master..xp_cmdshell ''bcp "select * from '+'tempdb'+'..'+'##temp_table_a'+'" queryout "c:/xxx/xxx.xls" -c -T '''
exec(@sql)
but the code column format change from 202211070002 to 202208E+11 and i want the result like the first one, is there a way to change the format with BCP? thank you ~ nb : lets say i dont want to use SSRS or some code stuffs
1 Reply
Accord
Accord3y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server