April 27, 2015 at 2:07 am
Hi Team,
using below query to compare columns in two tables.
SELECT
Col1 = ISNULL(a.name,b.name),
Col2 =
CASE
WHEN ISNULL(a.name,'') = '' THEN 'Table B'
WHEN ISNULL(b.name,'') = '' THEN 'Table A'
ELSE 'Table A & Table B'
END
FROM #tableA a
FULL JOIN #tableB b
ON a.name = b.name;
How to export the result to EXCEL from SQL Server 2008 R2.
April 27, 2015 at 2:31 am
April 27, 2015 at 3:13 am
Is there any possibility to export from SSMS without addins.
April 27, 2015 at 3:39 am
Copy / paste or Import/Export wizard are two possibilities.
-- Gianluca Sartori
April 28, 2015 at 3:11 am
From within Excel, you can also embed a Data Connection with your query in it. For example in Excel 2013, go to the Data tab and use the 'From Other Data Sources...' wizard to set this up. Select 'SQL' when you get to the Command Type menu choice.
This is perhaps not what you meant by 'Export' but it is another way to get data into a spreadsheet. It does not require SSMS or any add-in. It may be a bit more convenient if you need to re-run the query often.
April 28, 2015 at 9:08 am
Do you need .xls file at client computer or at the sever?
If it has to be a server side procedure i see two options.
1. Use OPENROWSET.
insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 8.0;Database=D:\222\myFile.xls;',
'SELECT [name], create_date FROM [MySheet$]')
select [name], create_date
from sys.all_views
It requiers some preparations. Be also ready to read criptic error messages when debugging.
2. Create an XML conforming to Office Open XML Formats https://technet.microsoft.com/en-us/library/cc179190.aspx
and just save it to file. No preparations, and it is compatible with other office software.
April 28, 2015 at 9:25 am
If the result set isn't too large copy paste works fine.
April 29, 2015 at 1:18 am
"This is perhaps not what you meant by 'Export' but it is another way to get data into a spreadsheet. It does not require SSMS or any add-in. It may be a bit more convenient if you need to re-run the query often. "
Minnu: as you give us little information about the purpose of your task I will continue on
the quotation above.
As your goal is to put information in Excel why not use the Tools in Excel. You don't have to struggle with T SQL. With PowerPivot you can connect to the database and use your question to fill a table in the PowerPivot database which you can use to present and analys information in Excel.
Gosta M
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply