Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mohithmv
Starting Member
8 Posts |
Posted - 2006-02-02 : 23:06:18
|
Hi All,I am generating HTML content from my SQL Stored Procedure.But when i open the HTML page once generated, after a fixed length the tags are getting wrapped and this results in improper rendering of cell content.Here is the Stored Proc Code(Only a part) which is used to generate the HTML.SET @OrderDetails = @OrderDetails + '<tr CLASS=''clsGrid''>' + '<td CLASS=''clsLabel'' ALIGN=''LEFT''>' + @VendorName + '</td>' + '<td CLASS=''clsLabel'' ALIGN=''LEFT''>' + @FoodItem + '</td>' + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @OrderDate + '</td>' + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @SlotDesc + '</td>' + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @FoodItemQty + '</td>' + '</tr>' here is my html source code which got rendered:<html><body><table><tr CLASS=clsGrid><td CLASS=clsLabel>Re-fuel</td><td CLASS=clsLabel>Butter Chicken</td><td CLASS=clsLabel>Jan 27, 2006</td><td CLASS="clsLabel"> 4:00PM</td><td CLASS=clsLabel>5</td></tr> <tr CLASS=clsGrid><td CLASS=clsLabel>Re-fuel</td><td CLASS=clsLabel>Butter Chicken</td><td CLASS=clsLabel>Jan 27, 2006</td><td CLASS=clsLabel> 7:30PM</td><td CLASS=clsLabel>6</td></tr> </table></body></html>I have made the part of the code, where it is getting wrapped, as bold. Due to this wrapping, the stylesheet class is not getting applied, sometimes the contents gets printed elsewhere on layout.I did come to know that a maximum of 1000 characters are allowed in a single line and the remaining sharacter string gets wrapped automatically.If i build the same HTML in my ASP or ASP.net & C #, it works fine.How can we avoid all HTML content being written in a single line.Can we incorporate line brakes before each TR or TD tags being generated in SQL Server 2000 Stored Proc? If so how?ThanksMohith |
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2006-02-02 : 23:26:57
|
Try adding char(13) where you want a line breakSET @OrderDetails = @OrderDetails + '<tr CLASS=''clsGrid''>' +char(13) + + '<td CLASS=''clsLabel'' ALIGN=''LEFT''>' + @VendorName + '</td>'+char(13) + + '<td CLASS=''clsLabel'' ALIGN=''LEFT''>' + @FoodItem + '</td>'+char(13) + + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @OrderDate + '</td>'+char(13) + + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @SlotDesc + '</td>'+char(13) + + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @FoodItemQty + '</td>'+char(13) + + '</tr>' |
|
|
mohithmv
Starting Member
8 Posts |
Posted - 2006-02-04 : 01:24:21
|
I did include both char(10) and char(13), but it is of no use. After every 999 characters, the line is getting wrapped physically.By including char(10) or char(13) each tr and td is getting displayed in new line, but the line itslf is getting wrapped after every 999 chars. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-02-04 : 10:31:07
|
It's probably whatever you are using to writ ethe file that is causing it.How are you doing that>I usually do this by writing the data to a table line by line with a sequence number then using bcp to export. It leaves you with the file image in a table which makes developement a lot easaier.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
mohithmv
Starting Member
8 Posts |
Posted - 2006-02-07 : 08:07:19
|
Hi All,got the fix.We postfixed Char(13) + Char(10)Code:SET @OrderDetails = @OrderDetails + '<tr CLASS=''clsGrid''>' + Char(13) + Char(10) + '<td CLASS=''clsLabel'' ALIGN=''LEFT''>' + @VendorName + '</td>' + Char(13) + Char(10) + '<td CLASS=''clsLabel'' ALIGN=''LEFT''>' + @FoodItem + '</td>' + Char(13) + Char(10) + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @OrderDate + '</td>' + Char(13) + Char(10) + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @SlotDesc + '</td>' + Char(13) + Char(10) + '<td CLASS=''clsLabel'' ALIGN=''CENTER''>' + @FoodItemQty + '</td>' + Char(13) + Char(10) + '</tr>' + Char(13) + Char(10) using Char(10) + Char(13) will not work. This is what we were doing earlier.Thanks for all your inputs.Mohith |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-02-07 : 08:14:58
|
Why the heck are you generating HTML this way if you have ASP.NET available to you? |
|
|
|
|
|
|
|