Search code examples
sql-server-2008vbscriptasp-classicvarcharmax

How do I use Varchar(max) output from a SQL Server 2008 stored procedure in an old ASP/VBScript app?


Here's the sproc:

ALTER PROC [dbo].[cms_createNoteMultipleRecID] (
  @NoteDt smalldatetime, 
  ...
  @NoteIDCSV VARCHAR(max) OUTPUT
)

And here's the VBScript:

cmd.CommandText = "cms_createNoteMultipleRecID"
cmd.Parameters.Append = cmd.CreateParameter("@RC", adInteger, adParamReturnValue)
cmd.Parameters.Append = cmd.CreateParameter("@NoteDt", adDBDate, adParamInput,, NoteDt )
...
cmd.Parameters.Append = cmd.CreateParameter("@NoteIDCSV", adLongVarWChar, adParamOutput )

Seems like adLongVarWChar works for input, as I have used it a few times. But, what's the proper way to use a varchar(max) output in VBScript? As-is, my error states: "Parameter object is improperly defined. Inconsistent or incomplete information was provided." from ADODB.


Solution

  • This works:

    cmd.Parameters.Append = cmd.CreateParameter("@NoteIDCSV", adBStr, adParamOutput, -1 )
    

    Open to better ideas.