locked
Adding a link to an external file into SQL table RRS feed

  • Question

  • I would like to add a link to an external file (picture stored on my local hard drive) into SQL table. Then use C# to query data from SQL table and export to Excel.  I got everything working ok except the link to external file. I would like to export this link to Excel and user can click on the link to open the file. How can I accomplish this? Thank you very much in advance for your help!

    Monday, October 13, 2014 11:22 PM

Answers

  • I am very new to SQL server and don't know much about it. However, I got a workaround solution for me. I added this line in my SQL query and it works for me
    
    SET [IMAGE1] = '=HYPERLINK("c:\Photos\' + @Image_name + 'a.PNG")'
    Thursday, October 16, 2014 11:56 PM

All replies

  • This sounds more like a .NET question. From an SQL perspective, the file path is just a string which means nothing to SQL Server.

    However, there may be alternate designs. Which versions of SQL Server are you using?


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Tuesday, October 14, 2014 10:58 AM
  • I am using SQL server 2012.
    Tuesday, October 14, 2014 5:03 PM
  • SQL won't do it. You would need to build the Excel file using a programming language like c# or VB

    Andy Tauber
    Data Architect
    The Vancouver Clinic
    Website | LinkedIn

    Tuesday, October 14, 2014 5:56 PM
  • In that case the Filetable feature could be of interest to you. With this feature the file can be part of the database, and still be accessible from tools outside SQL Server.

    I don't really have any good examples handy, but if anyone knows of a good blog post that could help Nhan, please feel free to add.

    Here is a link to the description in Books Online:
    http://msdn.microsoft.com/en-us/library/ff929144.aspx


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Tuesday, October 14, 2014 10:06 PM
  • I am very new to SQL server and don't know much about it. However, I got a workaround solution for me. I added this line in my SQL query and it works for me
    
    SET [IMAGE1] = '=HYPERLINK("c:\Photos\' + @Image_name + 'a.PNG")'
    Thursday, October 16, 2014 11:56 PM