How to convert character type to Memo type?

I have a Memo field in SQL. I know I can convert it to character type by
CONVERT(CHAR(255), f_memo)

But I have to convert this character type back to memo type. How to do that?
CastlewoodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick MatthewsCommented:
SQL Server does not have a memo data type.  Can you clarify what you need to do here?
0
CastlewoodAuthor Commented:
Sorry. That is a text field, not a memo. Then, can you tell me how to convert the text type back to Character type?
0
Patrick MatthewsCommented:
Why not simply use CONVERT?

SELECT CONVERT(text, CONVERT(char(255), f_memo))
FROM SomeTable

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Scott PletcherSenior DBACommented:
If you want to be sure you don't truncate data, you should use "varchar(max)":
CAST(f.memo AS varchar(max))
If you don't want to use "max", you can use up to varchar(8000).
1
David ToddSenior DBACommented:
Hi

In the past there were three large fields in SQL  text, ntext, and binary.

Now there is varchar( max ) and nvarchar( max ). These are meant to replace text and ntext.

I suggest that these days you should be using varchar( max ) or nvarchar( max ).

HTH
  David
0
Mayank GairolaSr. Application Support Engg.Commented:
You can use either of cast or convert like below -

 --Use CONVERT

select CONVERT (NVARCHAR(max),f_memo) FROM table1

--Use CAST

select CAST(f_memo AS NVARCHAR(max)) FROM table1

Though I would still prefer to go with CAST unless I am converting dates or date-time values. The reason being CAST is an ANSI standard, CONVERT is not.
0
Scott PletcherSenior DBACommented:
text data type should be converted to varchar(max). [ntext would be converted to nvarchar(max).]
0
CastlewoodAuthor Commented:
If text is now Varchar(max) then the result of CONVERT(text, CONVERT(varchar(255), f_memo))
is the same as CONVERT(varchar(255), f_memo).
Correct?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.