returning sysname data

  • I have a problem where I can't my sp to return me the correct value.

    the sp code is:

    CREATE PROCEDURE getKeyField

    @tableRef NVARCHAR(128),

    @keyField NVARCHAR(128) = NULL OUTPUT

    AS

    SELECT @keyField = constraint_name FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS (NOLOCK) WHERE TABLE_NAME = tableRef AND CONSTRAINT_TYPE = 'PRIMARY KEY'

    ***************

    If run the sp from Query Analyser, it works, but not from the asp.net web pages.

    The output parameter always returns null.

    Does anyone have any idea?

    Thanks,

    Eka

  • TRY THIS.......

    CREATE PROCEDURE getKeyField

    @tableRef sysname

    AS

    SELECT constraint_name FROM

    INFORMATION_SCHEMA.TABLE_CONSTRAINTS (NOLOCK)

    WHERE TABLE_NAME = @tableRef AND CONSTRAINT_TYPE = 'PRIMARY KEY'

    exec getKeyField 'TABLENAME'


    Andy.

Viewing 2 posts - 1 through 1 (of 1 total)

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