Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

supress output in query 1

Status
Not open for further replies.

Cretin

Technical User
Jan 2, 2003
194
0
0
US
I have a query it goes something like the following:

Select 'test folder'

select * from table.

The result set will be like the following:
1 test folder

1 record1
2 record2
3 record3
4 record4

I then need to use a third party product called goanywhere to write the results to a spreadsheet. The issue is It will only write the teat folder to the spreadsheet. Is what I need it to do is skip the 1stt results of test folder and only write the set of record to the spreadsheet, Is there any way to run a select but suppress the output from it.

Cretin
 
You only get a result and result window, when executing the query in SQL Server Management Studio from a query window. That's part of how SQL Server Management Studio works, not part of how SQL Server itself and the database engine work.

You use a third party language, be it C#.NET, VB.NET, Powershell, C++, whatever, and connect to SQL Server, Execute a script like your's with two queries, and get back results in whatever form is typical for the frontend programming language you use, eg a datatable or dataset with several datatables...

Seems you're not a developer, then you'll hardly get what you want in one go, but even SQL Server Management Studio itself will allow you to create spreadsheets from result windows and then you may use Excel to combine them.

Bye, Olaf.
 
You could try something like this:

Code:
[!]--[/!]Select 'test folder'

select * from table.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
gmmastros commenting the select folder out won't work I guess we need to use that.

Olaf, I am actually executing the SQL in a job scheduler but it may invoke SQL server manager behind the scenes to run the SQL. I am not absolutely sure why we need to select that folder prior to running as you are correct I am not actually a developer. Currently the process is ran manually the results copied into a spreadsheet then e-mailed. Is what I am trying to do is automate that process, that's kind of what I do I automate things.

Thank you both for all your help.

Cretin
 
SELECT 'test folder' is doing nothing but creating a single row, single column result with the text value 'test folder'. I don't see, that you need that at all. You might look at a script, that's actually not T-SQL, but something else. From what you describe this SELECT is necessary and doing something like changing directory or activating a certain database. But that's not what it does in T-SQL.

That script has two results, not only one, your job may only convert the first result into an excel sheet, then. Skipping it will give you the more essential data.

Bye, Olaf.
 
Thank you for your help everyone I talked to the users and developer that was only for documentation purposes which I have other ways to document it, thank you.

Cretin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top