Solved

HTML tags inside SQL text

Posted on 2009-07-07
8
596 Views
Last Modified: 2012-05-07
Can SQL text handle html tags?

What I mean is that I use html tags on SQL Text with the idea of
formatting the outgoing text. For example, see the code

I want to make "Mail option" as BOLD

If I use <B>Mail option</B>, smthng on this line? Can it be done?

SELECT @text= "If you just initiated a partnership with us, please complete the  form and return it along with requested documents to the address or fax number listed below.
 

Mail Option:

------------
 
 

Fax Option:

-----------
 

"

Open in new window

0
Comment
Question by:rbhargaw
8 Comments
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 100 total points
ID: 24798664
Sure. It is best if you use bind variables, so there is no need for escaping special characters like quotes, but otherwise, yes it works fine.

If you are asking if SQL itself cares about HTML, no, it won't make it bold in your output, it just treats it as literal text.
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 100 total points
ID: 24798666
sql can't, it treats that value as a varchar / nvarchar ;
0
 
LVL 6

Accepted Solution

by:
IncisiveOne earned 300 total points
ID: 24800781
(Sybase Only.)

The problem is that you think @text is a text variable, it isn't, there is no such thing (text, image and unitext are invalid for parameters and local variables).

You can place text/image in a column, and retrieve it.  That requires a programming language that uses the text/image operation of CT-Library; these program will bind the column directly to an internal (not external, such as SQL) memory location or variable.  SQL has no text operations, other than interrogating text/image pointers.  The stored text may well have embedded HTML tags or XML tags, indeed, it can be entire HTML or XML documents or images.  Again, all that is dependent on how the calling program handles it.  SQL is a database manipulation language, and has no HTML or XML capabilities.

the question is, where (what program, at what point) do you want to make some string of characters bold; ie. where do you want the transposition of tags to take place.  That should help you to decide where you place/store the tags.  Whether the character or text data you store in Sybase contains such tags is not relevant.

Cheers
0
 

Author Comment

by:rbhargaw
ID: 24807632
We have an mail application(VC++)  which uses outlook to send the email and attaches the text on the body of email.. That application call the stored procedure.The text  is hardcoded in Stored procedure. So based on above answers , I think I need to do may be a application level.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 6

Expert Comment

by:IncisiveOne
ID: 24810025
Yes.  That would be the easiest place and the most appropriate, since that is what hosts the interface between Outkook and the SQL database; that is what determines or providesmeaning to the content of the email (boody or headers).

Just to clarify:
1  since the sp if software, it is soft coded, not hard coded.
2  if you understand my post above, the sp does not manipulate the text column in the database; you will find that in the app.  The sp probably (and quite correctly) sets things up (such as insert/update/delete/get text pointer).

Cheers

0
 

Author Comment

by:rbhargaw
ID: 24810305
lol..isn't soft coding refers to bad programming itself :P
0
 
LVL 6

Expert Comment

by:IncisiveOne
ID: 24814314
If you have a program eg. to count the bytes in a file, and the program set the filename to something fixed, inside the program, it could only be changed by changing the program.  The user would have to change the name of the file to be read, to the fixed filename.  That's a hardcoded filename.  A qualified programmer would have the user pass the filename to be read as a parameter.

There is no term "softcoded", I was being a little bit tongue-in-cheek, and the term is easily understood in contrast to the established term, hardcoded.  All software is "soft", it is poor programming to hardcode anything that changes, such as an input filename.

When you said "the text is hardcoded", if you were referring to the text " If you just initiated a partnership with us... ", then no, that is not hardcoded.  It is a reasonable thing to place in a fixed string in the sp, and is not likely to change; it would be unreasonable to have that "softcoded" and passed every time, or read in from a table, etc.  And sps are very easy to change.

Cheers
0
 

Author Closing Comment

by:rbhargaw
ID: 31600836
Thanks Everyone!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now