Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to store a text field of a table into a variable?

Status
Not open for further replies.

Plato2

Programmer
Dec 6, 2002
192
0
0
US
I have a table with a column diclared as a text. Is it possible to save a field value of this text column into a variable?

Thanks in advance
 
i think this should work

declare @myText varchar(50)

select @myText = someCol
from myTable
where ...


 
NO I cannot do that
I have table
create (id int identity,message text)

I cannot assign text value to a varchar....
 
I think the only way you could do this is by creating a temp table with a text field. This temp table does not need to have more that 1 field or 1 record.

Create Table #TextTable (TextField Text)

Insert Into #TextTable(TextField) Select SomeCol From MyTable Where MyId = SomeValue

I know this will make writing the SP much more difficult. I.m sorry that I don't have a better answer for you.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Ok
In my case I need to get this variable(text) from the table
and then I need to pass this variable to a stored proc.
-------
Here is my table create (id int identity,message text).

I need to get "message" variable from this table and pass to a stored proc.
Here is stored proc:
sp_myStoredProc @message

create proc sp_myStoredProc @message as text.

How can I do that?
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top