Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
How to add multiline text in sql server 2005 ?
I have a reviews column to store reviews, so i need to store multi line text, how could i do this ?
Thanks!
Posted 27-Apr-13 22:22pm
Edited 27-Apr-13 22:32pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

select 'hello' + char(13) + char(10) + 'world'
/*
 
------------
hello
world
 
(1 row(s) affected)
 

*/ 
Look for CHAR in Books Online.
 
Hope this helps,
Pablo.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

But i have to insert paragraphs ??
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Easy: just use a parameterized query - you should be doing it anyway to avoid SQL Injection attacks:
string lines = "line1\nline2";
Or
string[] data = {"line1", "line2"};
string lines = string.Join("\n", data);
Then:
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (multiLineTextColumn) VALUES (@MLT)", con))
        {
        com.Parameters.AddWithValue("@MLT", lines);
        com.ExecuteNonQuery();
        }
    }
  Permalink  
Comments
Member 9898508 at 28-Apr-13 12:20pm
   
Thnks for ur advice .But let me expalin my problem . I have a reviews page for which user can read reviews and write reviews . so now whenever a user clicks a product the reviews stored in data base should be displayed and user can also write a review, which should be stored in data base..Now how can i store those big reviews in sql 2005 and how to display them in web page ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Thnks for ur advice .But let me expalin my problem . I have a reviews page for which user can read reviews and write reviews . so now whenever a user clicks a product the reviews stored in data base should be displayed and user can also write a review, which should be stored in data base..Now how can i store those big reviews in sql 2005 and how to display them in web page ?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 28 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100