Understanding Stored Procedures

  • I have created a database in SQL Server Express 2005 successfully. Now I need to create a stored procedure that will create a hyperlink to a specific website using just one key word 'Microsoft'. I have found the following script:

    CREATE PROCEDURE sp_FindTableNames

    (

    @ColumnName varchar(128)

    ) AS

    SELECT *

    FROM sysobjects

    WHERE id IN

    (

    SELECT id

    FROM syscolumns

    WHERE name = @ColumnName

    )

    AND xtype = 'U'

    But when I execute the script I get the following message

    'Msg 2714, Level 16, State 3, Procedure sp_FindTableNames, Line 6

    There is already an object named 'sp_FindTableNames' in the database.'

    What am I not understanding about this script.... :w00t:

  • Hey,

    You already have an object in the database with the same name (e.g. sp_FindTableNames) and you can now alter or drop only. Maybe you executed the query more than once?

    Cheers,

    Phillip Cox

    MCITP - Database Administrator

  • terrence_daniels (2/28/2008)


    I have created a database in SQL Server Express 2005 successfully. Now I need to create a stored procedure that will create a hyperlink to a specific website using just one key word 'Microsoft'. I have found the following script:

    CREATE PROCEDURE sp_FindTableNames

    (

    @ColumnName varchar(128)

    ) AS

    SELECT *

    FROM sysobjects

    WHERE id IN

    (

    SELECT id

    FROM syscolumns

    WHERE name = @ColumnName

    )

    AND xtype = 'U'

    But when I execute the script I get the following message

    'Msg 2714, Level 16, State 3, Procedure sp_FindTableNames, Line 6

    There is already an object named 'sp_FindTableNames' in the database.'

    What am I not understanding about this script.... :w00t:

    Hello,

    You requirement says that you want to create a stored procedure which will create a hyperlink to a specific website and the script says to find a table name if the column name which you passed as input variable exists.

    Please reply with your actual requirement and somebody online will be able to help you.

    Thanks


    Lucky

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

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