Urgent Questionshow can i fill #table from sp

  • Hi team i am trying to fill #table form sp and i don't know , the following my statement:

    the sp returned the columns in the #table.

    create TABLE #TestTable (FunctionalityID int, PageCode nvarchar(250), NameE nvarchar(250), ControlType nvarchar(250), ControlName nvarchar(250))

    INSERT INTO #TestTable(FunctionalityID , PageCode , NameE , ControlType , ControlName )

    SELECT (execute [spNavigation_GetUnAuthorizedFunctionalities] 55)

    thanx in advance

  • Hi

    Whats it that you want to know

    "Keep Trying"

  • i am but really i need help 🙁

  • We know that, but we don't know what help you need. Was the query you posted successful? If not, in what way was it not? Did it produce an error message, or did it not insert all the rows into the table that you expected?

    John

  • Chandrachurh Ghosh (4/28/2008)


    a #table has a local scope, so it will not work.....

    Not true. A temp table will persist until it is dropped or the user connection terminates. There's no reason the query shouldn't work, unless the table is wrongly defined or the stored procedure produces more than one result set.

    John

  • my temp table name is #TestTable

    create TABLE #TestTable (FunctionalityID int, PageCode nvarchar(250), NameE nvarchar(250), ControlType nvarchar(250), ControlName nvarchar(250))

    INSERT INTO #TestTable(FunctionalityID , PageCode , NameE , ControlType , ControlName )

    (SELECT execute spNavigation_GetUnAuthorizedFunctionalities 55)

    DROP TABLE #TestTable

    in the previous statment i got the following error msg:

    Incorrect syntax near the keyword 'execute'.

    Incorrect syntax near ')'.

    the statement sound good logically but its not working

  • Yes, I should have spotted this the first time. Just get rid of the SELECT and it should work.

    If you ever get a syntax error message, your first port of call should be Books Online to check the syntax of the command you are using.

    John

  • You cannot use -

    INSERT INTO #TestTable(FunctionalityID , PageCode , NameE , ControlType , ControlName )

    SELECT (execute [spNavigation_GetUnAuthorizedFunctionalities] 55)

    You have to use -

    INSERT INTO #TestTable(FunctionalityID , PageCode , NameE , ControlType , ControlName )

    execute [spNavigation_GetUnAuthorizedFunctionalities] 55

    and it will work only if the no. of columns and the data types are same.

    Chandrachurh Ghosh
    DBA – MS SQL Server
    Ericsson India Global Services Limited
    Quality is not an act, it is a habit.

  • yes its working now

    thank u 🙂

Viewing 9 posts - 1 through 8 (of 8 total)

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