Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Server/DTS: text field to char field

Posted on 2008-10-22
2
Medium Priority
?
337 Views
Last Modified: 2013-11-30
I'm accessing an existing SQL 2005 table that has a TEXT field with length of 2147483647. The data in the field is character-delimited.  (If I want to find the Date of Service, I'd have to look for "DATEOFSERVICE" and date would appear shortly after that.)

Is there a way to do this?  

Does the TEXT field need to be convert to char?  If so, how?

Thanks, Ashley
0
Comment
Question by:BCAshleyP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
DBAduck - Ben Miller earned 1500 total points
ID: 22780716
Text fields cannot be manipulated like a varchar field.  So you would have to convert it to varchar(4000) or whatever length is long enough.
In SQL 2005 you should use varchar(max) instead of text because then you can just do a charindex() instead of conversion and charindex().

CONVERT(varchar(4000), textfield1)

Does that help?
0
 

Author Comment

by:BCAshleyP
ID: 22781673
Thanks!  For some reason I couldn't get it to work (operator error I'm sure), but this led me to the obvious: I copied the data into a new table (I don't own the original table), but defined the text field X as varchar(max) in the new table.  This seems to work.

THANKS again for your help!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question