Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to add border style to the table for an html content fetched from an SP in sql server?

Without setting border style it works fine. But I want to set so from the back end.

What I have tried:

The HTML code I tried in SQL is as below:
SQL
SET @HTMLCode = '<HTML>'        
SET @HTMLCode = @HTMLCode + '<table style="border:1">'
SET @HTMLCode = @HTMLCode + '  <tr>'
SET @HTMLCode = @HTMLCode + '    <th>' + 'Sl No:'  + '</th>'
SET @HTMLCode = @HTMLCode + '    <th>' + 'Pending Count'  + '</th>'
SET @HTMLCode = @HTMLCode + '    <th>' + 'Received Date'  + '</th>'
SET @HTMLCode = @HTMLCode + '  </tr>'
SET @HTMLCode = @HTMLCode + '  </table>'

But above code is not working.
Posted
Updated 24-Feb-16 8:40am
v2
Comments
ZurdoDev 24-Feb-16 12:38pm    
1. Returning HTML from SQL is a bad idea, but if you have to, I understand.
2. Where are you stuck? Just add border.
Richard Deeming 24-Feb-16 14:35pm    
I've fixed your code formatting - the HTML tags weren't visible.

1 solution

Your style declaration is incorrect. You're missing a unit on the border width. You also need to specify the border style, and optionally the border colour as well.

Try using the correct CSS syntax for the border:
HTML
<table style="border:1px solid black;">

CSS border property | W3Schools[^]

Or just setting the older "border" attribute:
HTML
<table border="1">

HTML table tag | W3Schools[^]
 
Share this answer
 
Comments
Arunprasath Natarajan 25-Feb-16 0:33am    
Yes this works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900