I am trying to create something for our QA people, where a query that they would run will return a column with hyperlinked values. I am using SQL Server 2008 R2 and SSMS.
How will I hyperlink results in SSMS so a linked value opens in a browser?
The idea is that the Qa person can simply click on the link and the appropriate ASP.Net app would open in a browser window.
The query is as below, which is right now showing an unlinked string under DocLink column.
SELECT
DocNumber,
'https://www.xyz.com/mypage.aspx?docNumber=' + CAST(DocNumber AS varchar(20)) AS
DocLink
FROM Docs
You can do it using string concatenation. Note that this just return the url as a string; to show it as a hyperlink you have to add the appropriate html tags, but that should probably be done in the presentation layer of your application.
SQL Server provides us with two methods in T-SQL to assign a value to a previously created local SQL variable. The first method is the SET statement, the ANSI standard statement that is commonly used for variable value assignment. The second statement is the SELECT statement.
There is no way that I found to open URL directly from result pan but following is the way if you want to achieve open hyperlink from within SSMS
.
Step 1. Cast the result to XML. i.e.
SELECT CAST('http://www.google.com' AS XML) Google
Step 2. After executing the query, in the result window, click on the hyperlink. That will open another tab in SSMS.
Step 3. In this new tab, right click on the link and select Open URL option. This will open the link into the default browser.
Try that.
Cast the result string as XML:
SELECT
CAST('https://www.xyz.com/mypage.aspx?docNumber=100' AS XML)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With