You must Sign In to post a response.
  • Category: SQL Server

    Can we use temp tables inside function

    Can we use temp tables inside function.
    if yes how, give me one example...
  • #648516
    [Response removed by Admin. Read forum policies.]
    Dharmendra Kumar
    dharmendra.hbti@gmail.com
    +919911308352
    http://blog.dkumar.co.in

  • #648544
    Naresh,

    You cannot use Temporary tables inside a function in sql server
    Instead you can use table variable in sql server

    The concept over here is user defined function will not allow to perform any DDL(Data Definition Language) operation.

    If you use Temp Table, You can create index in it, but in Table variable you cannot perform any table level operation like alter table etc.

    That's why temp table is restricted in Sql Server User-Defined function.

    Please mark this as Answer, if this helps

    Regards,
    Alwyn Duraisingh.M 
    << Database Administrator >>
    Jesus saves! The rest of us better make backups...

  • #648585
    You cannot use temp tables in functions. However, you can use table variables.
    Regards
    Mr.Rajesh
    Software Engg.


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.