Export a Table or Query results from SQL Server to Excel



hello friends welcome back to secure with Manoj today I will show you how to export a table or a query data from sequel server to an excel file so I will take you to SSMS here we have a table that is employ and these are the contents of this table okay and we have around 290 records in this particular table so today we will see how to you know export this table from sequel server to excel so I have so right now I have this you know e drive and Excel folder here and there is nothing in here so what I'll be doing is I'll be creating a new file and dumping the data okay so you have to just you know wherever this table is located in the database you have to go to the database and right click and select task and here you have to go to export data right so this exported option will open you the import and export wizard here just click on next so this particular window asks you what is the source of the table ok so choose a data source here you will have to select this and scroll down and choose sequel server Native Client 11.0 ok here you have to choose the server name so my name is you can see here mano chip and l so this is my server name and database name is you know pre-populated if it is not that then you have to select it from the list now click Next and here it it asks you to choose a destination and our destination is an excel file so we'll choose Microsoft Excel ok and it asks you which version so what I'll do is I'll choose the latest version that is MicroBot Excel 2007 although I'm having sequel server I think 2015 installed on my PC but it shows me the 2007 so I'll choose it and I'll choose first row has column names and it asked me what is the file path so I will click on browse and take you to a drive and Excel folder and here I'll create a new excel file and name it employee data ok and choose this and click on open so set with the destination I'll click next so it it asked me you know what kind of data you want to copy from one or more tables or views or a query so first of all I will show you how to you know select a table so click Next and I'll choose tbo dot employ and in the destination you can change the employ so I'll put employ employ table ok then click Next and click Next run immediately find click Next and just click on finish I think a success and 290 rows transferred just close it and go to the folder and you will see a new excel file created that we created before migrating the data and after migrating if you open it it will show you you know all the data populated so it creates a new sheet so you will see you know nothing is there because it is a sheet one you have to switch to the second sheet that is employ table so employ table if you remember then we chose this name I added this table name I had this table you know after this employee so this is my you know table dump of full 290 records ok so let us close this ok save now I'll show you how to you know you we we just saw that you know we selected the table now if you have query instead of this table so let's say if I have a query say top hundred records I just want to select top Android records so what I will do I will copy this query ok and I'll use this query over here go to task export data now click Next here again I have to select my source that is my sequence our and database is already set click on next then my target that is Microsoft Excel and 2007 file path is same file ok and we are not going to dump the data in the same sheet we'll create a new sheet I'll show you here write a query to specify the data to transfer ok then click Next and do is paste this over here and click on parse it says the sequel statement is valid I'll click next and here it shows me you know query so what I'll do is I will put here very employ employee query top hundred okay so the new exit sheet will be created this particular name and all hundred records will go into that okay I'll click Next okay next next and finish I close it and move to the folder where the excel file is kept now click on open ok and if you check this a third sheet is created that is improv-y query top hundred and if you see here only hundred God Squad copied right so this is how you can export a table or a query data from sequel server SSMS to an excel file thank you for watching this video in my next video I'll talk about something similar so please stay tuned thank you

23 thoughts on “Export a Table or Query results from SQL Server to Excel

  1. if we want to add some data in employee table … will it automatically be store in excel file.??
    and my 2nd question is that what is the procedure to make a xml file instead of excel file .. or we can save this excel file as xml file.?? i am waiting your answer … thank you

  2. Can we create excel file using query for the sql query without using bcp command… Can you suggest me

  3. how can we write a query to save the data in a specific sheet of a workbook without using the export function.? I just want to write query and do this stuff

  4. Have you heard about SQL Complete https://www.devart.com/dbforge/sql/sqlcomplete/productivity-extension.html ? I've found a lot of good feedbacks about it. What do you think about this tool, is it worth to using it?

  5. I have SQL 4.0.  There is no right-click>Task Menu, etc.  How do I export to Excel with SQL 4.0?? Thanks!

  6. Thanks for exploring both options in data dumping – all records as well as specific query records …nice video !!

Leave a Reply

Your email address will not be published. Required fields are marked *