Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HTML tags inside SQL text

Posted on 2009-07-07
8
Medium Priority
?
659 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 400 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 400 total points
ID: 24798666
sql can't, it treats that value as a varchar / nvarchar ;
0
 
LVL 6

Accepted Solution

by:
IncisiveOne earned 1200 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
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

926 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