Table Values UDF are getting hang when i am writing below query
select * from FN_Retun (123)
it dose not return any output and stays in the running mode and when check with sql profiler nothing was blocking to it (somehow CPU usage got hike)
but when i run the underlying Select query of the function it takes only 3 sec.
I have also drop and recreated the function but getting the same problem.
Below is the rough definition of the function ( can not provide complete code)
Create Function FN_Retun (@id bigint)
RETURNS @METRICS TABLE
(OPEN_YN VARCHAR(50),ADDED_YN CHAR(1),CLOSED_YN CHAR(1),LN_SK_ID BIGINT,
TOTAL_COUNT INT)
AS
BEGIN
DECLARE @UPLOAD_DATE DATETIMEDECLARE @UPLOAD_DATE_SK_ID BIGINT
SELECT @UPLOAD_DATE = UPLOAD_DATE,
@UPLOAD_DATE_SK_ID = UPLOAD_DATE_SK_IDFROM DATE_DM
INSERT INTO @METRICS
/* below select runs in 2 sec*/
select OPEN_YN,ADDED_YN,CLOSED_YN,LN_SK_IDCOUNT(NUMBER) AS DM_COUNT
from table_1 inner join table_2 on id1 = id2 and id3 = @id
where ------many condition------
group by OPEN_YN,ADDED_YN,CLOSED_YN,LN_SK_ID
RETURN
END
Kindly help .