Solved

HTML tags inside SQL text

Posted on 2009-07-07
8
631 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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
 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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