Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Using TEXT in subquery or Stored Procedure...how?

Author  Topic 

binggeli
Starting Member

20 Posts

Posted - 2005-11-08 : 10:06:07
Is there any way to use the contents of a TEXT field
in a subquery within a Stored Procedure?


My situation:

Need to copy partial row information from
existing table "A" with INT, VARCHAR and
TEXT fields into existing table "B" -- this
is custom work for one of our clients who
does not want to have to do this manually
for 1,000's of users in an HR system.


However, the TEXT field in question has
never more than 500 characters, so I would
be happy if I could even do something with
VARCHAR(500) (say, in a variable).

Nothing I've tried seemed to work.

I can't CAST the contents of the TEXT field
into VARCHAR.

I can't use SUBSTRING.

I can't use LEFT or any of those string
functions.

Keep getting the "The text, ntext, and image data types are invalid in this subquery or aggregate expression." message.


Any ideas or suggestions?

Thank you,
Dee

X002548
Not Just a Number

15586 Posts

Posted - 2005-11-08 : 10:17:17
Try this

SELECT CONVERT(varchar(500),textColumn)


Post the DDl if you want a more complete solution



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

binggeli
Starting Member

20 Posts

Posted - 2005-11-08 : 10:21:39
Thank you!

It worked. I can't tell you how grateful I am
for your solution.

Sometimes you guys just make my day!


Thanks much,
Dee
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-09 : 01:01:10
>>I can't use SUBSTRING.

Substring will work on TEXT Column

Select SubString(TextCol,1,500) from yourTable

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -