Spatial Results Tab window not available in Microsoft Visual studio - sql-server

I cannot see the 'spatial results' tab window when i run the query below.When i run a normal query i can see 2 tabs showing 'results' and 'message' but not the 'spatial results' tab. I am using Microsoft visual studio2017(ssdt).The codes below works fine but it displays the columns as text and coordinates but not in a grid format.Can someone tell me how to get the spatial results tab.Is there something that i need to download.Please advise.
Create table [Spatialinfo]
(id INT,spatialdata geometry,shape Varchar(10));
INSERT INTO [spatialinfo]
(spatialdata)
VALUES ('Point(7 12)');
Select * From Spatialinfo;
The result that i get is something approximately as follows in the message window.
id spatialdata shape
1 0x000010c0000022400000002840 null

"The codes below works fine but it displays the columns as text and coordinates but not in a grid format"
The documentation explicitly states that if you are returning your results as text, you will not get the Spatial Results Pane. Spatial Results Window:
Note
The Spatial results window is only available if your results are
returned to a grid in the Results window. If you specify that your
results are returned as text, this window is not available.
You need to return your results in the Grid View to see the Spatial Results Window.

Related

Showing image in a SSRS report using BIDS for CRM 2011

I am building a SSRS report in BIDS for CRM 2011 on-premise. My report needs to show an image attached to the annotation ID of the record.
I have two images attached to one record and three records in total. What is happening is that when I run the report, the image is shown with the first record of the report only and that is not the record the image is attached too.
Here is my sql query for the report.
select Annotation.DocumentBody,
inmate_FirstName, inmate_LastName,inmate_MiddleName,inmate_BookingNumber, inmate_InmateNumber,inmate_DOB,inmate_Gender,
inmate_BookingDate, inmate_Race
from new_bookingscreen1 left outer join
Annotation on new_bookingscreen1.new_bookingscreen1Id = Annotation.ObjectId
What my guess is that when I add the image control in the report, it is just simply showing me the image and is not in anyway related to the report. As in there is no connection between the report query pasted above and the image control.
How do I solve this?
I am using this =First(Fields!DocumentBody.Value, "DataSet1")
in the expression field of the image tool.
How do I bind the report query result to the image tool result?
You are using First() Function of SSRS which Returns the first value from the specified expression. Try this
=Fields!DocumentBody.Value
The only Bring forward the Imagies you actually need by doing something like ..
select Pic.Col1, inmate_FirstName, inmate_LastName,inmate_MiddleName
,inmate_BookingNumber, inmate_InmateNumber,inmate_DOB,inmate_Gender,inmate_BookingDate, inmate_Race
from new_bookingscreen1 OUTER APPLY (
SELECT TOP 1 Annotation.DocumentBody
FROM Annotation
WHERE ObjectId = new_bookingscreen1.new_bookingscreen1Id
ORDER BY -- Your Condition (How you decide which one is the 1st Picture)
) Pic(Col1)

How can i get the nth row field into image in SSRS 2008r2 - Report Builder 3

I have a report which is just one page per record. The record is chosen using a parameter.
On this report I have space for 4 images, I have a dataset called "AdditionalPhotos". I would like to put the image from the first four rows of this dataset into each of the spaces on the report.
To do this, I planned on using an expression with a function like : First(Image), Second(Image), Third(Image), Fourth(Image). I now realise that SSRS only supports First() and Last() so using some advice from another forum post : http://social.msdn.microsoft.com/Forums/sqlserver/en-US/20493945-578a-4d83-ae3b-e603a3473ac6/nth-row-element-in-a-dataset-ssrs
I have implemented another dataset which contains the same query as the "AdditionalPhotos" but with only 2 columns "ID" and "RowNum". Using this expression I can see a Photo Source field in a textbox, which is great, so the syntax is working.
=Lookup(1,Fields!Row.Value,Fields!Source.Value, "AdditionalPhotos")
In the value field for the image I have :
=Lookup(1,Fields!Row.Value,Fields!Image.Value, "AdditionalPhotos")
This doesn't work, I just get a red x icon in the image box of the report. I have the correct MIME type setting and have confirmed this by changing the expression for the image box to :
=Fields!Image.Value
Any advice or suggestions would be great.
In your SQL you can use the ROW_NUMBER() window function to generate row numbers based on an order and/or a partition so that you can select which image you want where.
Something like:
SELECT Image,
ROW_NUMBER() OVER(ORDER BY id) AS rownum
FROM imageTable
See:
MSDN - ROW_NUMBER (TSQL)
MSDN - OVER Clause

Need help printing query results to a file/text

This SSMS newbie is trying to print the results of a query instead of having it directed to the grid
I followed the following steps:
Management Studio -->> Tools -->>Options -->>
Query Results -->>General -->> Results to text and c:\works as Default location for saving query
Query Results -->>SQL Server -->> Results to text -->>Include column headers when copying or saving...
yet, when query is executed, I don't see the results at all
could someone please shed the light my way as to how can I get the query results saved to a file that I can print later on?
If you send the results direct to file, you can't see them in the Results pane in SSMS.
You have three choices:
Results to Text (plain text, in the Results pane)
Results to Grid (grid view, with resizeable columns & rows similar to Excel)
Results to File (writes direct to file, results not displayed)
You can choose between these options from the Query -> Results menu, buttons on the Standard toolbar, or keyboard shortcuts (CTRL-T,CTRL-D, CTRL-SHIFT-F, in the order above). Select your output "mode", then execute the query.
With the first two options, you can right-click the results and save to a file from there. Or copy/paste elsewhere.
With Results to File, it will output the results in a file in your default location (c:\works\ in your case) but it should prompt you with the standard Windows File Save dialog.
You need to select "Results to File" not "Results to Text". When you then go back and run your query, you will not see any query results, just a prompt for the file name you want to save the results as.
You don't want Results to Text. You want Results to File. Then, when you execute the query, you'll be prompted for the file name to save under.

DLookUp behavior in Form_Current with Label Captions

Access 2010 here.
Ok, Dlookups appear behave different based on where they are used. I have this Dlookup
inside a ClockNo_AferUpdate() subroutine that works well on new form entries to change a label's caption to what is found in the "Employees" DB under "EmployeeName" field based on the entered "ClockNo" in a ClockNo combo-box:
Me.LabelName1.Caption = DLookup("[EmployeeName]", "Employees", "[ClockNo] =" & Forms![InspectionEntryForm]!ClockNo)
The Employees database has four fields: AutoNumber-type "ID," Number-type "ClockNo," Text-type "Shift," and Text-type "EmployeeName."
Re-EDIT:
The RowSource for the ClockNo combo box as it sources from the Employees database:
SELECT DISTINCTROW [ClockNo], [EmployeeName] FROM [Employees] ORDER BY [ClockNo];
END Re-EDIT
What I am looking for is the same functionality in Form_Current() so browsing through older entries preserves the Label's caption based on the entered ClockNo. Unfortunately, simply re-using the above Dlookup gives a "Run-time error '3075': Syntax error (missing operator) in query expression '[ClockNo] ='."
Attaching the Dlookup as a control source to a text box does work O.K, but labels seem to be the best use here. I have mucked about with the Criteria section of the Dloopkup for some time without any real success.
End goal is to have a simple label next to a combo box that displays the employee's name based on their current and past ClockNo entries. The name is stored in a separate Employees database alongside their clock number and their shift.
This should be quite simple as both the ClockNo entry and the Label operate on the same form with the same database. Thanks for your input!
You have a combo box named ClockNo with this as its Row Source:
SELECT DISTINCTROW [ClockNo], [EmployeeName]
FROM [Employees]
ORDER BY [ClockNo];
I'm not sure why you want DISTINCTROW there. I would have suspected DISTINCT to be more appropriate. But I don't think it matters.
The important point is that the combo already includes [EmployeeName], so you shouldn't need to use DLookup to fetch [EmployeeName] again. Simply read the value from the second column of the combo's selected row.
Imagine your form includes a text box named txtEmployeeName. In the form's current event, you could do this:
Me.txtEmployeeName = Me.ClockNo.Column(1)
Notice the column index numbers start with 0, so the second column is .Column(1).
And you could do the same thing in the combo's After Update event.
Finally, you wanted to change a label's .Caption, but I showed you how to change a text box's .Value. If you can't make this technique work with the label, just use a text box instead. You can set the text box's Enabled property to No and adjust its other properties so that it is visually indistinguishable from a label.
Another approach could be simpler still. If you want to keep [ClockNo] as the combo's bound value, but are willing to display [EmployeeName] as the combo's selected value, you can set the width of the first column ([ClockNo]) to zero. You would still see both [ClockNo] and [EmployeeName] in the dropdown. If this is acceptable, you wouldn't need to bother with a label or text box.

How to list all columns of a given sql query

is there an easy way to get a list of all columns of a SQL query?
They are listed in the header of the results window of SSMS but I can't copy them.
Thanks in advance.
EDIT:
sorry, I found it myself after a little googling:
http://vidmar.net/weblog/archive/2008/06/05/save-sql-query-results-with-column-names-in-msssms.aspx
Go to Query -> Query Options and check the following box
If you change to Results To Text, then you can copy them.
To save actually executing the full query just to get the column names, you could also do:
SET FMTONLY ON;
SELECT * FROM SomeTable;
This will just return the metadata about the columns the query returns. Saves waiting around if the query is meaty.
Change the result window to 'Results to text' instead of 'Results to grid'.
This can be done by clicking of the on of the Icons above the query window. It looks somewhat like a notepad icon.

Resources