How to import SQL Server excel and SQL Server excel
-- Importing data from an Excel file to a SQL database is simple. Use the following statement: /* ===================================================== =============================*/-- if the table to be imported already exists insert into Table select * from OPENROWSET ('Microsoft. JET. OLEDB.4.0 ', 'excel 5.0; HDR = YES; DATABASE = c: \ test.xls', sheet1 $) -- if data is imported and the select * into table from OPENROWSET ('Microsoft. JET. OLEDB.4.0 ', 'excel 5.0; HDR = YES; DATABASE = c: \ test.xls', sheet1 $) /* ===================================================== =============================*/-- if the SQL database, export data to Excel. If the Excel file already exists and the header has been created according to the data to be received, you can simply use insert into OPENROWSET ('Microsoft. JET. OLEDB.4.0 ', 'excel 5.0; HDR = YES; DATABASE = c: \ test.xls', sheet1 $) select * from table -- if the Excel file does not exist, you can also use BCP to import Excel-like files. Note the case sensitivity: -- export the table EXEC master .. xp_mongoshell 'bcp database name. dbo. table name out "c: \ test.xls"/c-/S "server name"/U "username"-P "password" '-- export query status EXEC master .. xp_cmdshell 'bcp "SELECT au_fname, au_lname FROM pubs .. authors order by au_lname "queryout" c: \ test.xls "/c-/S" server name "/U" username "-P" password "'/* -- Note: c: \ test.xls is the Excel file name for import/export. sheet1 $ is the worksheet name of the Excel file. You must add $ to use it normally. --*/
How can I export the query results in SQL server 2008 to an Excel table?
After the query is complete, press CTRL + A in the result bar to select all the results, right-click and select "Save the result... and save it as "*. csv file, you can open it in excel. Or copy the results to an excel table by copying the results together with the title.
How does SQL server Import excel documents?
In SQL server 2000, there is an import and export tool that can be used to export various types of data.
You can also right-click any table on the Database Management Interface (Enterprise Manager), or choose import/export.
Versions later than 2005 support copying and pasting, which is no different from operating files in this tutorial.