We help IT Professionals succeed at work.
Get Started

SQL trigger and DataType "text"

Last Modified: 2021-04-21
I have a table (tblInfo) with a field called "info". This field has DataType = text.
The table has a SQL Trigger that needs to do a select from the "info" field. Because of the DataType (text) I get this error:

[Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables]

Here is my code:

ALTER TRIGGER [dbo].[trgHandler]
   ON  [dbo].[tblInfo]
   for insert

      DECLARE @msg varchar(4)
      DECLARE @info varchar(max)

      SET @msg = (select msg from INSERTED)
      SET @info = (select info from INSERTED)  -- THIS FAILS!

      IF (@msg = '1234')
        -- Do something with @info here...

My question is: How can I get the text from the "info" field in my SQL trigger?
Watch Question
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE