none
WEB PROBLEM

    Вопрос

  • In database having one table in that table contains weblinks.when click on that web link open the InternetExplorer. how to write the query

    For Example:Table Name AAA

    Company        CompanySite

    acs                 www.acs.com

    jpmorgan       www.jpmorgan.in

    TCS                https//tcs.com

    In this table contain Company names and Link here write a code In this table execute that code click on  any CompanySITE FILED OPEN THAT SITE IN IE.How to do this one

    Regars & Thanks

    Vinodkumar.kapa


    Vinodkumar.kapa

    8 июня 2012 г. 14:21

Все ответы

  • Select Company, CompanySite
    FROM AAA
    That will get you the data.  The rest is all a function of your web app code


    Chuck Pedretti | Magenic – North Region | magenic.com

    8 июня 2012 г. 14:23
  • If u click on any url open into IE.How to to this one 


    Vinodkumar.kapa

    8 июня 2012 г. 14:29
  • If u click on any url open into IE.How to to this one 


    Vinodkumar.kapa

    Where are you returning the data - to an applciation?  Or are you trying to make a clickable link appear in SSMS?

    Chuck Pedretti | Magenic – North Region | magenic.com


    8 июня 2012 г. 14:33
  • I am not sure what you are asking for.  do you want to open the link in SSMS or do you want to have your application open the URL returned by the appliation.  You can have our application use a hyperlink for the url returned by the query.  something like

    <a href="http://www.google.com.com">Google</a>

    If you want this to show up in SSMS you can use xml to initially click the link (this will open a new window).  In the new window you can ctrl-click to launch the site in SSMS.

    ** Just select from your table like you normally would, as shown below.

    DECLARE @t TABLE(
    Id INT,
    URL VARCHAR(MAX)
    );
    
    INSERT INTO @t VALUES (1,'http://www.google.com');
    INSERT INTO @t VALUES (2,'http://www.yahoo.com');
    
    SELECT [processing-instruction(x)]=URL
    FROM @t
    FOR XML PATH(''),TYPE


    http://jahaines.blogspot.com/

    • Предложено в качестве ответа Naomi NModerator 8 июня 2012 г. 16:24
    8 июня 2012 г. 14:49
    Модератор
  • Correct me if I'm wrong, but I get the impression this is a query, whose output is sent via email or pasted into a spreadsheet, word document, or other piece of software that automatically detects that it's a URL, and dynamically makes it a clickable hyperlink.   Or, the results are presented in an application that you're responsible for, and the application treats the URL as a clickable hyperlink.

    In other words, this isn't specifically a SQL Server issue, it's a case where you don't want the software you're using to automatically treat the URL as a hyperlink.

    Options:

    • If it's your own application:  Using the application code, prevent the data from being converted to a hyperlink.
    • Excel:  Do a google search; there isn't a "one-click" answer.  There's a "five or six click" answer, but not a "one click" answer.  It is annoying.  Generally, right click, choose "delete hyperlink" from the context menu.
    • Email/Word doc:  Also awkward.  RIght click and delete hyperlink works.  Possibly try "paste special" and paste as text too, but turning off auto-detect of hyperlinks is hard to automate completely.
    • SQL solution:  (to dodge, but not solve the problem):  Replace https://, http://, and 'www.' with an empty string.

    Example REPLACE code:

    ;With LIST (URL) as 
    (
    Select 'www.yahoo.com' 
    UNION ALL Select 'yahoo.com' 
    UNION ALL Select 'http://www.yahoo.com' 
    UNION ALL Select 'https://www.yahoo.com' 
    UNION ALL Select 'http://yahoo.com' 
    UNION ALL Select 'https://yahoo.com'
    )
    Select *
      , Replace(
         Replace(
          Replace(URL, 'www.', '')
         , 'http://', '')
        , 'https://', '') as Delinked
      From LIST



    • Изменено johnqflorida 8 июня 2012 г. 15:37 Fixed typo, added sample
    8 июня 2012 г. 15:31
  • Actually, a bit more dependable:

    ;With LIST (URL) as 
    (
    Select 'www.yahoo.com' 
    UNION ALL Select 'yahoo.com' 
    UNION ALL Select 'http://www.yahoo.com' 
    UNION ALL Select 'https://www.yahoo.com' 
    UNION ALL Select 'http://yahoo.com' 
    UNION ALL Select 'https://yahoo.com'
    UNION ALL Select 'https://www.WhatIfANameContainedwww.com'
    )
    Select *
       From LIST
      Cross apply (select  Replace(
    			Replace(URL, 'https://', '')  
    			, 'http://', '') as Delinked
    		) as CA_StripHTTP
     Cross Apply (Select Case When Patindex('www.%', Delinked) = 1 
    			  then Substring(Delinked, 5, 999) 
    			  else Delinked 
    		     End as Delinked2) as CAStripWWWOnlyAtFront
      
    

    8 июня 2012 г. 15:54
  • JohnQFlorida,

    Now that you say that about another client like an email, it makes a bit more sense.  To make the results of an email's body formatted for hyperlinks he would have to stored the HTML hyperlink in the table or compute it at runtime, something like below would work.

    DECLARE @t TABLE(
    Id INT,
    URL VARCHAR(MAX)
    );
    
    INSERT INTO @t VALUES (1,'http://www.google.com');
    INSERT INTO @t VALUES (2,'http://www.yahoo.com');
    
    WITH HTMLTableDetail(HTMLContent)
    AS
    (
    SELECT [td/a/@href] =  URL, [td/a]=URL
    FROM @t
    FOR XML PATH('tr'), ROOT('table'), TYPE
    )
    SELECT 
    	(select HTMLContent from HTMLTableDetail)	
    FOR XML PATH('body'), ROOT('html'), TYPE

    Anyway, we will need more infor before moving forward with this post

    http://jahaines.blogspot.com/

    8 июня 2012 г. 16:21
    Модератор
  • Thanks for given reply but click on output url link open the that link.for example in out put shown www.google.com when i click that one its open in IE shows google site.is it possible or not .i am click on link in SSMS

    Vinodkumar.kapa

    8 июня 2012 г. 18:31
  • Unfortunately, and forgive us for having difficulty, we still don't understand your request. Let's try summarizing:

    - You are viewing the output of a query or report in SSMS.

    - Please clarify to us what you want to happen next, if a user clicks on a URL:

      (a) You DO want IE to open up to that site?

      (b) You do NOT want IE to open up to that site?

    - Please answer (a) or (b) to the above question.

    If you answer is (a), then use Adam Haines' latest reply.  If you answer is (b), use JohnQFlorida's latest reply.

    8 июня 2012 г. 18:45
  • Hi John,

                  Requirement is already design one table in contains two column one is Name and another one is URL.This is table structure.here i want to write a code when click on that link URL Fields open IE not in application level. is it possible or not in sql server.answer(a) working in ssms only.not open in separately IE


    Vinodkumar.kapa

    9 июня 2012 г. 18:35
  • I don't think that is built specifically into SSMS itself.  SSRS would let you do that.

    A two step workaround, is to "Select cast('www.yahoo.com' as XML)", then click the XML link to open an XML tab, then control-click the URL to open in a new window.  You can also control-click the URL in the query body (in the SQL).

    10 июня 2012 г. 10:35
  • I return  the  data to an application level


    Vinodkumar.kapa

    11 июня 2012 г. 8:32
  • Hi Johnqflorida,how to do this issue in reporting.actually what happen is front end is using .net and back end is using reporting services.here is going to preview click on url open the into IE.here is working fine .when deploy to this report not working in front end.i pass the parameter click on ok .it shown report when i was click on that url its open the same window come to back parameter was not working again click on that report after pass the parameter like that only


    Vinodkumar.kapa

    11 июня 2012 г. 11:56