Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2015-02-20 : 13:02:41
|
Hello - Can anyone help me? I have been trying to find a way to export the results of a query to a csv for use in excel but cannot. Can anyone help with this?Its really frustrating, such an easy idea but so difficult. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-02-20 : 14:21:34
|
There are a few ways. You can use the import/export wizard: right click on the database, tasks, export data. You'll specify a query for the source.You can also use bcp.exe, save results as option in SSMS, or OPENROWSET.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
pradeepbliss
Starting Member
28 Posts |
Posted - 2015-02-24 : 04:31:12
|
1) First enable XP_cmdshell in sql server then go to step 2 Use Master GO EXEC master.dbo.sp_configure 'show advanced options', 1 RECONFIGURE WITH OVERRIDE GO EXEC master.dbo.sp_configure 'xp_cmdshell', 1 RECONFIGURE WITH OVERRIDE GO 2)EXEC xp_cmdshell 'bcp "SELECT * FROM DBName.TableName" queryout "E:\Pradeepbliss.csv" -T -c -t "|",' |
|
|
|
|
|