Stored Procedure with NTEXT argument

  • I have an NTEXT column on a table and I wish to select that column into an NTEXT output argument. I have searched through the books on-line but none of the example actually show how to yank the data from column to argument.

  • Off the top of my head (I don't have SQL at home) I'm not sure if TEXT and NTEXT are allowed as output parameters but the general format is

    CREATE PROC dbo.MyProc @myVar INT OUTPUT

    AS

    ...etc

    GO

    Then in the calling proc

    DECLARE @lResult INT

    EXEC dbo.MyProc @lResult OUTPUT

    You have to specify the OUTPUT both in the declaration and when you call it.

    If you sometimes want to call the procedure but don't want all the fuss of declaring the output variable all the time then supply a default value as follows

    CREATE PROC dbo.MyProc @myVar INT=0 OUTPUT

    AS

    ...etc

    GO

  • Text, NText and Image types are all allowed as stored procedure arguments. Thank you, Ten Centuries for the tip about executing a stored procedure within TSQL, but I am calling the stored procedure from within .NET code.

    My problem lies in copying the image or Ntext column (no final decision as to which to use) to the image or NText argument.

  • Hi,

    problem is that T-SQL does not allow assigning value to image, text or ntext variable.

    If you wish to return value from ntext column from a table, use SELECT statement. You will have the value in recordset.

    Have in mind that procedure can return multiple recordset.

    Darko


    First rule of debugging:
    No Code, No Bugs

  • Thank you,

    I have already written a recordset method to retrieve of the value. I have however seen a method described for getting the column value into an output variable.

    In the longer term, the system is moving to SQL 2005 and the column can become NVARCHAR(MAX)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply