question

RichRauch avatar image
RichRauch asked

Can a char field contain a line feed?

My customer wants to store a multi-line text string in a char field. Is it possible to include a line feed when entering data on a form to be stored in a char field? Shift-Enter doesn't do it.
sql-server-2005stringcharacters
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JohnM avatar image
JohnM answered
In short, yes you can store line feeds in the table. However, is your question more about how to gather that information from the UI to store it? Maybe from a web form? If so you might want to post your question over to other sites such as stackexchange.com. Just as an example: CREATE TABLE #test (NAME CHAR(100)) GO INSERT #test VALUES ('asdfasdf asdfasdf asdf asd') GO SELECT * FROM #test GO If you copy the results of the select out it should include the line breaks as well as the tabs.
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hmm, that interesting as using "Results To Grid" worked fine for me, however it could be that I'm using SSMS 2012 now that I just noticed you tagged the question as SQL 2005. ;-)
1 Like 1 ·
That does work (but, in SSMS, only after switching to "Results to Text" rather than "Results to Grid"). But, you're right, I'm asking about how to get the input from the UI. I'll try stackexchange.com. Thanks!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.