Knowledge Base

Document information

Document ID: 5204
Subject: Special Comments in WinSQL
Creation date: 3/16/18 11:28 AM
Last modified on: 3/16/18 11:28 AM


WinSQL Special Comments

WinSQL supports several comments that are meant to enhance the functionality of queries you write. This page lists those comments. All of these comments are Line Comments. In other words, they start with two dashes.

For Example
-- wn_SaveToCSV C:\Temp\Customer.csv select * from Customer where state = 'NJ'

Important!

You must run queries in Grid to use the special comments


Available Comments

CommentDescription
-- wn_NamedQuery Specifies a name for a Named Query. This value is useful when you try to save a named query.
-- wn_PageTitle Specifies a name for current Query Page.
-- wn_SaveToCSV Saves the results of a SELECT query to a text file in CSV format. This comments takes a file name as parameter representing the path for the output file.

For Example
-- wn_SaveToCSV C:\Temp\Customer.csv select FirstName, LastName, sum(Cost) as TotalOrderValue from Customer INNERT JOIN Orders ON Customer.ID = Orders.ID where state = 'NJ'


-- wn_SaveTabDelimited Similar to CSV, this comment saves the output of a SELECT query to a tab-delimited file.
For Example
-- wn_SaveTabDelimited C:\Temp\Sample.txt select FirstName, LastName, sum(Cost) as TotalOrderValue from Customer INNERT JOIN Orders ON Customer.ID = Orders.ID where state = 'NJ'
-- wn_SaveToHTM Similar to CSV, this comment saves the output of a SELECT query to a HTML file.
For Example
-- wn_SaveToHTM C:\Temp\Sample.htm select FirstName, LastName, sum(Cost) as TotalOrderValue from Customer INNERT JOIN Orders ON Customer.ID = Orders.ID where state = 'NJ'
You can optionally change the style sheet used by WinSQL when exporting to HTML. This done by modifying htmlHead.txt file in the DataFolder
-- wn_SaveInsertStatements Saves INSERT INTO statements based on a SELECT query.
For Example
-- wn_SaveInsertStatements C:\Temp\Sample.sql,CustomerOrders select FirstName, LastName, sum(Cost) as TotalOrderValue from Customer INNERT JOIN Orders ON Customer.ID = Orders.ID where state = 'NJ'

This comment takes two parameters:

  1. Name of the file
  2. Target table name

Each parameter is separated by a comma. A table name will be assigned based on the name of the file if the second parameter, table name, is omitted.

-- wn_ShowColumnInfo Displays the metadata for a SELECT query.
For Example
-- wn_ShowColumnInfo select * from dbo.Customer c where Dop >= GetDate() - 1
-- wn_TabTitle This is a convenient way to specify a title for the tab in the grid. This becomes useful if you need to save the contents of a result grid.
For Example
-- wn_TabTitle One Day Cust select * from dbo.Customer c where Dop >= GetDate() - 1


User comments

Posted by George Soulis on 9/21/18 2:03 AM

I just found out about these special comments and I think it's a great idea. I just hope they were not only working when the query is run in grid mode. It would be very nice if "wn_TabTitle" could be used in text mode to give the query results a title.


Add a comment to this document

Do you have a helpful tip related to this document that you'd like to share with other users?

Important: This area is reserved for useful tips. Therefore, do not post any questions here. Instead, use our public forums to post questions.

Navigation

Social Media

Powered by 10MinutesWeb.com