SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to Best store this data


How to Best store this data

Author
Message
AndrewSQLDBA
AndrewSQLDBA
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1836 Visits: 3427
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
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7991 Visits: 25280
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
Mark Eckeard
Mark Eckeard
SSC Veteran
SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)

Group: General Forum Members
Points: 271 Visits: 505
.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



Eugene Elutin
Eugene Elutin
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5128 Visits: 5478
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!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
sandeep rawat
sandeep rawat
Right there with Babe
Right there with Babe (735 reputation)Right there with Babe (735 reputation)Right there with Babe (735 reputation)Right there with Babe (735 reputation)Right there with Babe (735 reputation)Right there with Babe (735 reputation)Right there with Babe (735 reputation)Right there with Babe (735 reputation)

Group: General Forum Members
Points: 735 Visits: 376
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)
AndrewSQLDBA
AndrewSQLDBA
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1836 Visits: 3427
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
Eugene Elutin
Eugene Elutin
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5128 Visits: 5478
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!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Mark Eckeard
Mark Eckeard
SSC Veteran
SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)SSC Veteran (271 reputation)

Group: General Forum Members
Points: 271 Visits: 505
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



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search