EXEC, EXECUTE, sp_executesql

  • Hi

    What is th difference between next queries and sp (EXEC, EXECUTE, sp_executesql)?

    Thank you

  • EXEC and EXECUTE are identical - one is just shorter than the other. sp_executesql supports parameter substitution and it generates execution plans that SQL Server can more readily reuse than EXEC, which makes it more efficient.

    Check out sp_executesql in books online, it gives a good overview there.

  • What is th difference between next queries and sp (EXEC, EXECUTE, sp_executesql)?

    Okay - the first thing that went thru my head was this (before my AM coffee. It's Friday...its been a long week, at least for me):

    SELECT (LEN('EXEC') + LEN('EXECUTE')) - LEN('sp_ExecuteSQL')

    so, the answer, as I saw it this morning, is, -2 :w00t:

    -- Cory

  • SQLZ (4/11/2008)


    EXEC and EXECUTE are identical - one is just shorter than the other. sp_executesql supports parameter substitution and it generates execution plans that SQL Server can more readily reuse than EXEC, which makes it more efficient.

    Check out sp_executesql in books online, it gives a good overview there.

    EXEC and EXECUTE also supports parameters. can you explain detail about sp_executesql . since i have not been used

    shamsudheen

  • shamshudheen (4/11/2008)


    SQLZ (4/11/2008)


    EXEC and EXECUTE are identical - one is just shorter than the other. sp_executesql supports parameter substitution and it generates execution plans that SQL Server can more readily reuse than EXEC, which makes it more efficient.

    Check out sp_executesql in books online, it gives a good overview there.

    EXEC and EXECUTE also supports parameters. can you explain detail about sp_executesql . since i have not been used

    shamsudheen

    Did you check out Books OnLine as the previous post stated?

    http://msdn2.microsoft.com/en-us/library/ms188001.aspx

    http://technet.microsoft.com/en-us/library/ms175170.aspx

    -- Cory

Viewing 5 posts - 1 through 4 (of 4 total)

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