0
SELECT        
    Table1.SourceName, Table2.TableName, Table3.SourceSQL, 
    Table1.SourcePath, Table4.ProcessType
FROM
    Table1 
INNER JOIN
    Table3 ON Table1.SourceID = Table3.SourceID 
INNER JOIN
    Table2 ON Table3.ID = Table2.ID 
INNER JOIN
    Table4 ON Table1.ProcessID = Table4.ProcessID
WHERE        
    Table2.TableName = '[EXCEL COLUMN 1 ROW 1]' 
    OR Table2.TableName = '[EXCEL COLUMN 1 ROW 2]' 
    OR Table2.TableName = '[EXCEL COLUMN 1 ROW 3]' 
    ...OR Table2.TableName = '[EXCEL COLUMN 1 ROW N]';

The query itself is not my question - there may be some inconsistencies because I altered table/row names in the Select and Join statements.

I'm focused on the Where clause - is there a way I can pull records from an excel spreadsheet (records all in the same column) into this query without writing each one in manually. I'm using MS SQL Server Management Studio 2014.

Let me know if more information is needed.

7
  • You can't use SSMS to "query" an Excel sheet so what are you asking? Did you mean to ask about the Import Wizard? Or are you using OPENROWSET? Commented Jun 28, 2016 at 14:04
  • I mean: Is there a way to mount this excel file into SQL server manager to pull all the rows from the first column into my query? I'm not sure if it is possible - would import serve that function? I don't want to create a table. Commented Jun 28, 2016 at 14:05
  • Why don't you want to create a table? In fact, why do this on SQL Server when PivotTable offers columnstore functionality on the client? Commented Jun 28, 2016 at 14:06
  • This is for the purpose of pulling info from an existing DB to create a report. Commented Jun 28, 2016 at 14:08
  • Then why don't you load the data in a table? Commented Jun 28, 2016 at 14:11

1 Answer 1

1

You could try installing the access database engine from here https://www.microsoft.com/en-us/download/details.aspx?id=13255 and trying to create a linked server to the excel sheet as mentioned here https://social.msdn.microsoft.com/Forums/sqlserver/en-US/3019b4ec-fd3e-41c3-8f2e-cd85dc180ef4/sql-2012-64-bit-linked-server-to-excel-2013-64-bit?forum=transactsql

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I ended up using a PowerShell script to search the .XML steps where the data I needed was stored, but this would have been much better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.