Configuring SQL Server Surface Area before using OPENROWSET
03 |
sp_configure 'show advanced options' ,1 |
05 |
reconfigure with override |
07 |
sp_configure 'Ad Hoc Distributed Queries' ,1 |
09 |
reconfigure with override |
Connecting from SQL Server to SQL Server with OPENROWSET (Windows Authentication)
5 |
FROM OPENROWSET( 'SQLNCLI' , 'Server=server1;Trusted_Connection=yes;' , |
6 |
'SELECT GroupName, Name, DepartmentID |
7 |
FROM AdventureWorks.HumanResources.Department |
8 |
ORDER BY GroupName, Name' ) AS a; |
Connecting from SQL Server to MS Access Database with OPENROWSET
3 |
SELECT CustomerID, CompanyName |
4 |
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0' , |
Connecting from SQL Server to an Excel File using OPENROWSET
5 |
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0' , |
6 |
'Excel 8.0;Database=c:\data.xls' , [Sheet1$]) |
Connecting from SQL Server to text file using OPENROWSET
5 |
( BULK 'C:\data.txt' ,SINGLE_CLOB) |
Generating an excel document with the output of a query
1 |
insert into OPENROWSET( 'Microsoft.Jet.OLEDB.4.0' , |
2 |
'Excel 8.0;Database=D:\testing.xls;' , |
3 |
'SELECT * FROM [SheetName$]' ) select * from SQLServerTable |