SQL Server Performance

Facing problem with UDFs

Discussion in 'General Developer Questions' started by if_farhan, Apr 16, 2008.

  1. if_farhan New Member

    Hi,
    I have made user defined function which takes two parameters; the first one is int and and second one is char(1). I am using this UDF three times with different parameters in my query. It works fine on my development machine but when i do the same query on live server it will overwrite last two calls with first call resultset. Below is the sample query for what i am trying to do:-
    Select count(dbo.fn_GetContractCount(ContractID,'T'))[Total], count(dbo.fn_GetContractCount(ContractID,'N'))[New], count(dbo.fn_GetContractCount(ContractID,'U'))[USED] from tbl_Contract Where SaleDate between '01/01/2007' and '01/01/2008'
    Results on my machine:
    Total New Used
    12 9 3
    Results on live server:
    Total New Used
    12 12 12
    Kindly reply ASAP. i will very thankful.
  2. madhuottapalam New Member

    Check the data in production. Dev ENV may not be in sync with production env. It must run, also check the query u run both env
    Madhu
  3. Adriaan New Member

    What does the UDF actually do?

    Have you tried writing this as a proper aggregate query, without UDFs?

Share This Page