Call a procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaleidoscope
    New Member
    • Jul 2010
    • 5

    #1

    Call a procedure

    Hello,
    Slowly with me plz; I'm new to T-SQL :)
    I hope someone can help with this. I created a stored procedure that is meant to generate a table, but when I call it (EXEC procedure_name) nothing happens (i.e.: checked to see if the table was created but couldn't find any).

    - The SQL statements in the procedure seem OK (no error messages)
    - The procedure doesn't take any parameters

    Did I call the procedure correctly?

    Zied
  • kaleidoscope
    New Member
    • Jul 2010
    • 5

    #2
    It looks like there is an error in t-sql syntax...
    Can anyone see an error here please:

    IF EXISTS (SELECT name
    FROM sysobjects
    WHERE name = N'CreateTransit iveClosure'
    AND type = 'P')
    DROP PROCEDURE CreateTransitiv eClosure

    GO
    CREATE PROCEDURE CreateTransitiv eClosure

    AS

    declare @sql varchar(1000)

    select @sql='insert into tClosure SELECT CONCEPTID1, CONCEPTID2, 1 AS steps FROM Relationships where RELATIONSHIPTYP E=3'
    execute (@sql)

    GO

    EXECUTE CreateTransitiv eClosure
    GO

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      Looks like this is wrong
      Code:
      WHERE name = N'CreateTransitiveClosure'
      Can't have N their

      Comment

      • kaleidoscope
        New Member
        • Jul 2010
        • 5

        #4
        Actually, it does not appear to be wrong. The Store procedure was indeed created and saved. If I run the script again it does not tell me that the procedure already exists so the problem shouldn't be there. Any help?

        Comment

        • ck9663
          Recognized Expert Specialist
          • Jun 2007
          • 2878

          #5
          Your sample did not generate a table, the table is already existing. If the table is not existing, your SP would return an error. Check which database you created your SP and which database you created your table. If all is working well, that means there are no relationshiptyp e = '3' on your Relationships table.

          Good Luck!!!

          ~~ CK

          Comment

          • kaleidoscope
            New Member
            • Jul 2010
            • 5

            #6
            I feel stupid :) Thx kindly, ck9663, you hit the nail right on the head! Need to create the table first. Cheers, Z

            Comment

            Working...