问题
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
回答1:
Cast the result string as XML:
SELECT
CAST('https://www.xyz.com/mypage.aspx?docNumber=100' AS XML)
回答2:
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.
来源:https://stackoverflow.com/questions/18832132/hyperlink-a-value-in-sql-server-query-result-in-ssms