Hi,

I am trying to select a data column of text datatype from a table into a local variable.
However, this variable always returns a 'NULL' value. Below is a snippet of my code. Please help. I am trying to extract the datatext of the inserted row and it is of text type. Thanks!


DECLARE @XMLDoc varchar(8000),
@XMLFileName varchar(20),
@TranKey char(10),
@direction char(1),
@RepositoryKey char(10)

SELECT @XMLDoc=''

SELECT @TranKey=a.RepositoryKey, @XMLDoc=a.datatext, @XMLFileName=SUBSTRING(a.FileName,1,20), @direction=a.direction
FROM GC_REPOSITORY a (nolock), INSERTED b (nolock)
WHERE a.RepositoryKey=b.RepositoryKey


Alternative that I am trying:-

SELECT @TranKey=b.RepositoryKey, @XMLFileName=SUBSTRING(b.FileName,1,20), @direction=b.direction
FROM INSERTED b (nolock)

SELECT @XMLDoc=a.datatext
FROM GC_REPOSITORY a(nolock)
WHERE a.RepositoryKey=@TranKey