Format SQL query results - sql

I am looking for a way to set the width on the returned column result from a SQL query.
I run a query like Select Product from ConfigScheduling where Product is an Nvarchar(Max) column.
The result in SQL Server Management Studio with Results to Grid is a 90 char wide visible column, with the full result present, but not visible.
Thank you

Couldn't find it by default, but if you double-click on the right part of the Column Header it will stretch like in Excel.

Tools>Options>Query Results>SQL Server>Results to Grid>Non XML data
Tools>Options>Query Results>SQL Server>Results to Text>Maximum number of characters displayed in each column.
If these still don't suit your needs, you'll need to use another tool such as bcp or sqlcmd/osql.

If I remember correctly, SQL Server Management Studio cannot pull the whole nvarchar(max) field into display and won't attempt to either. The only way to fully access the resultset is to use a third party tool or display it in a gridview or something in a webapp.

Related

find column name in sql query

I would like to use the GUI to find q column name in my sql query which has more than 300 columns
For example: I want to use GUI provided by SQL to find all the column names starting with VENDOR and hi-light them in order to make my operation easier..
I just want to use GUI
P.S: No query suggestions please, I am already aware of them (using like and all)
In MSQL Studio, use the Query Designer (Design Query In Editor...), paste your SQL, then use the name column in criteria pane to copy and paste in excel

How to include 'NULL' value in Microsoft SQL server Report Builder

I would like to include NULL value from the database in Micorsoft SQL Server Report Builder 2012.
Problem:
Whenever I try to include NULL value in parameter drop-down list.. I can't sort by 'NULL' values in my report.
You mean like the Null values go last?
Well I had problems when I tried to order my results by Query or by hand (I mean, like selecting how to order in the tablix) because none of this would work at all.
It will result for sure if you use "Dynamic Order". :)
It's not too "Comfortable" to use it because when you run the report you will have to click in the column you will use as a reference to order your report and when it's done you will be able to sabe or print your report.
It would be great if it ordered the results by itself by just running the report but it won't work.
:) I hope I could help.

SQL Server Management Studio show complete content of field varchar(max)

There is a way in SQL Server Management Studio to read all the contents of a varchar(max) column when you run a select?
I know that there is an option in Options > Query Execution > SET TEXTSIZE. But I was wondering if are something like when you have a XML file that you can click the cell and a new tab is open with the cell contents.
No - there is no direct way to get full cell data in SSMS grid. SSMS truncates it.
But: SSMSBoost add that I develop does what you need: it allows to copy cell contents 1:1. All bytes, even if there are megabytes !
http://www.ssmsboost.com/Features/ssms-add-in-copy-results-grid-cell-contents-line-with-breaks
Have you tried results to text?
Here's a screenshot / guide:
http://blog.sqlauthority.com/2007/07/19/sql-server-2005-ssms-viewsend-query-results-to-textgridfiles/

SQL Server 2005 select query not retrieving complete text from a column

Maybe this would be very simple, but I have no idea why this is happening.
To put in simple way, I have inserted a row into a database table which contains a ntext column called content. String value which got in to this column content has a text length of 6889 characters. However when I do a basic select query based on id, it do retrieve the row - but not the complete text from the column Content. All I see in SQL Server Management Studio for this column when I do a select query is the text with characters 43679.
There is no issue with data being inserted and I could see all the text being displayed in front end application. The issue is only when I do a select query, and copy the text to notepad, I do see fewer characters. Anything with respect to SQL Server settings/paging/statistics? Appreciate if anyone could help me out with this.
thanks,
KK
I encountered similar problem, and I found that SSMS is unable to fully retrieve column that is longer than 43680 (in output to Grid mode).
So the work around is output it as XML (unlimited length):
SELECT convert(xml,'<xml><![CDATA[' + cast([your column] as varchar(max)) + ']]></xml>')
Then do a quick search and replace (< to < , > to > ) . You can now copy the result to Notepad++ to view all the content.
SSMS returns a maximum number of characters to the grid or text window of every text based column: SSMS menu: options: Query results node : SQL node : Results to grid / Results to text
I'm sure there is a good reason for this: probably SSMS would fall over even more regularly than it does now.
Hope this helps... no such thing as a silly question

Copy SQL 2005 view result column headers?

Is there a way to copy View output column headers along with the data? There is a setting in Options to include column headers with query results, but that only works with "New Query" and Stored Procedure output.
Looks like SSMS 2008 has this functionality built in to the contextual menu when you right click on results, but I only have 2005.
Am I out of luck?
Thanks for any help.
It works if you SELECT * FROM VIEW_NAME in a regular query window. If you Open a view like you Open a table to show data, it won't copy the columns - that's a different, editable grid.
Tools, Options, Query Results, SQL Server, Results to Grid. There's an option in there for it.