December 23, 2011 at 5:57 am
Hi!
In ssms you can set the results to text instead of grid.
Would it be possible to output the text in a query so I can use it on the web?
Placing it in a textarea for example?
Hope this is optional π
Best,
Peter
Example
name object_id principal_id schema_id parent_object_id type type_desc create_date modify_date is_ms_shipped is_published is_schema_published lob_data_space_id filestream_data_space_id max_column_id_used lock_on_bulk_load uses_ansi_nulls is_replicated has_replication_filter is_merge_published is_sync_tran_subscribed has_unchecked_assembly_data text_in_row_limit large_value_types_out_of_row is_tracked_by_cdc lock_escalation lock_escalation_desc
-------------------------------------------------------------------------------------------------------------------------------- ----------- ------------ ----------- ---------------- ---- ------------------------------------------------------------ ----------------------- ----------------------- ------------- ------------ ------------------- ----------------- ------------------------ ------------------ ----------------- --------------- ------------- ---------------------- ------------------ ----------------------- --------------------------- ----------------- ---------------------------- ----------------- --------------- ------------------------------------------------------------
patients 1691153070 NULL 1 0 U USER_TABLE 2010-07-20 13:19:01.993 2010-07-20 13:19:01.993 0 0 0 0 NULL 3 0 1 0 0 0 0 0 0 0 0 0 TABLE
(1 row(s) affected)
December 23, 2011 at 6:07 am
Search for 'Results to Text' in following article.
SQL Server Management Studio Database Engine Query Editor Window
December 23, 2011 at 6:16 am
Results to Text
Returns the query results as text in the Results window.
I want the result via the web. This means I'm using a VB.net file which runs the query.
No ssms π
December 23, 2011 at 6:22 am
peter 50174 (12/23/2011)
Results to Text
Returns the query results as text in the Results window.
I want the result via the web. This means I'm using a VB.net file which runs the query.
No ssms π
What exactly are you struggling with?
Do you already get the data in your VB script? If so, then it shouldn't be a problem to format it using VB. If that's what you're looking for, you might want to ask in a VB forum since this seems to be a front end issue.
December 23, 2011 at 6:32 am
What exactly are you struggling with?
Do you already get the data in your VB script? If so, then it shouldn't be a problem to format it using VB. If that's what you're looking for, you might want to ask in a VB forum since this seems to be a front end issue.
I could solve this front end. But first I would like to know if it is possible to get the results as text and not as grid.
I believe grid is default or maybe the only way.
When using grid I would require objRS("first_name").ToString() etc....
When using text I think objRS(0).ToString() would be enough.
I think it might be query configurable to get text instead of grid.
That's why I ask here first π
December 23, 2011 at 6:38 am
It can be achieved with SQL query but I wonβt recommend you that. As Lutz has already suggested, please do it on Front End. Thatβs the right place for such operations.
December 23, 2011 at 6:40 am
Would that be like adding an option or creating temp tables and other fancy stuff?
December 23, 2011 at 6:42 am
your are confusing the two possible presentation styles of SSMS with how the actual results end up in your other .NET application...they are not the same.
you get a record set back as multiple rows and columns. the presentation layer(SSMS,an application , a web page) can manipulate those rows of data to a desired format.
For your web page on the .NET/server side, you'd simply loop thru the results and stick them into a string variable, then set the textbox(textarea actually) value to that string.
that is exactly what SSMS is doing...
Dim FinalString as String
For Each dr As DataRow In dt.Rows
For i As Integer = 0 To dt.Columns.Count - 1
FinalString = FinalString & GetString(dr.Item(i)) & vbCrLf
Next
Next
Response.Write("<TEXTAREA id=""results"">" & FinalString & "</TEXTAREA>")
that is esxactly what SSMS is doing in Textmode: massaging the results into a single string, and then setting the text of the RTF to that value.
Lowell
December 23, 2011 at 6:42 am
peter 50174 (12/23/2011)
What exactly are you struggling with?
Do you already get the data in your VB script? If so, then it shouldn't be a problem to format it using VB. If that's what you're looking for, you might want to ask in a VB forum since this seems to be a front end issue.
I could solve this front end. But first I would like to know if it is possible to get the results as text and not as grid.
I believe grid is default or maybe the only way.
When using grid I would require objRS("first_name").ToString() etc....
When using text I think objRS(0).ToString() would be enough.
I think it might be query configurable to get text instead of grid.
That's why I ask here first π
You're looking at it from the front end perspective already. What you consider a "grid", is a result set with rows and columns. If SQL Server send this result set to a file, it will be plain text. If it's send to SSMS, it's either text or a result set (configurable by the "front end" SSMS).
It is possible to create a single column result set (e.g. comma separated list) using SQL Server directly. But that's not really the best option.
Why don't you transform the grind into text in your VB app? Isn't VB capable of doing that?
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply