Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to Best store this data Expand / Collapse
Author
Message
Posted Monday, August 20, 2012 6:06 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, July 17, 2014 3:19 PM
Points: 975, Visits: 3,342
Hello Everyone
I am working on one of my own .NET websites that stores data in SQL 2008 database.

I would like to store the data to be able keep the paragraphs that are typed in from the front-end.


For example:
blah, blah, blah, this really has nothing to do with the data itself, but more of the formatting.

Now to view this data on a website, to keep all the original formatting, one would do something like this. Or one could do this........


I want to keep that paragraph correct when I store that data in a column with a Varchar(max) data type.

Thank you in advance for all your help.

Andrew SQLDBA
Post #1347521
Posted Monday, August 20, 2012 6:41 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:36 PM
Points: 5,565, Visits: 24,699
Have you checked on the many posting here on SSC for keeping XML data ? Suggest that it might be worth your while to check those and then make a decision as to how you are going to store your data and retain its original format.

Scroll up to the top of this page and in the right hand corner in the box with the word "search" simply type in XML format and click on the GO button.


If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #1347527
Posted Tuesday, August 21, 2012 5:28 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, May 9, 2014 11:34 AM
Points: 128, Visits: 489
.NET has the ability to capture and pass the HTML to a sproc and you can store it as varchar(max) like you said. I did this on a few customer web pages I built for users that wanted text to appear exactly as they typed it, including < br > and < p > tags.

Mark



Post #1347721
Posted Tuesday, August 21, 2012 5:49 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, July 4, 2014 3:55 AM
Points: 2,836, Visits: 5,062
And let me suggest you one tip:

Store duplicate of your data without any formatting... You should get unformatted text when you save the data from UI, as it's easy in .NET.
It does happen quite often, that very soon you will be asked if this data can be included into report or some thing else, removing HTML or other formatting tags from saved text - will be much harder task...



_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1347727
Posted Tuesday, August 21, 2012 6:39 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: 2 days ago @ 12:52 AM
Points: 716, Visits: 350
Plz read
http://www.sqlmag.com/article/c3/store-rtf-data-in-a-sql-server-database

For SQL Server 2005 and up, use VARCHAR(MAX) / NVARCHAR(MAX) if you're dealing with pure text files (like source code or CSV files), or VARBINARY(MAX) if you're dealing with binary files.

Those allow up to 2 GB of storage for each single file, and you can use all the usual T-SQL string functions on them to manipulate them (the (N)VARCHAR(MAX) fields, that is).

If you're using SQL Server 2008, there's also an additional option - the FILESTREAM attribute on VARBINARY(MAX) columns. This allows you to store the files in the SQL Server machine's file system (instead of the database tables) while preserving transactional and data integrity.

FILESTREAM is recommended for files that are typically and usually larger than 1 MB in size, or if you ever need more than 2 GB (since you can't store more than 2 GB in a regular VARBINARY(MAX)
Post #1347748
Posted Tuesday, August 21, 2012 7:05 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, July 17, 2014 3:19 PM
Points: 975, Visits: 3,342
Is there anything Special that I need to do within my .NET code to force the issue of keeping the tags in place? Or by default, will they be there? I am using C# as my OOP language.

I could probably use a smaller varchar(2000) data type, I doubt if there will ever be anything large stored. It is only the steps of a recipe.

Thanks
Andrew SQLDBA
Post #1347764
Posted Tuesday, August 21, 2012 7:55 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, July 4, 2014 3:55 AM
Points: 2,836, Visits: 5,062
AndrewSQLDBA (8/21/2012)
Is there anything Special that I need to do within my .NET code to force the issue of keeping the tags in place? Or by default, will they be there? I am using C# as my OOP language.

I could probably use a smaller varchar(2000) data type, I doubt if there will ever be anything large stored. It is only the steps of a recipe.

Thanks
Andrew SQLDBA



AndrewSQLDBA (8/21/2012)
Is there anything Special that I need to do within my .NET code to force the issue of keeping the tags in place? Or by default, will they be there? I am using C# as my OOP language.

I could probably use a smaller varchar(2000) data type, I doubt if there will ever be anything large stored. It is only the steps of a recipe.

Thanks
Andrew SQLDBA


It's depends of what control you are using.
All RTF controls should be able to return formatted and unformatted text.
You may consider to use NVARCHAR datatype if your text will contain some unicode characters...


_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1347802
Posted Tuesday, August 21, 2012 9:19 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, May 9, 2014 11:34 AM
Points: 128, Visits: 489
You can get by storing the data once and removing the formatting for reporting purposes if needed.

I used this free tool to build a wysiwyg kind of editor within a web page:

http://www.freetextbox.com/

Look up htmlencode and htmlencode and that should help.

Mark



Post #1347868
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse