How do i test the table value function?

362 views Asked by At

I just try to excute the below query .Its giving me

ERROR:

   Msg 208, Level 16, State 3, Line 1
    Invalid object name 'dbo.f_getPeopleTabRowCounts'.



SELECT *
FROM dbo.f_getPeopleTabRowCounts(7424,'YYYYYYYYYYYYY','abcd','Y');

Anyone can help me pls.

How do I test a Table-Valued Function in SQL Server Management Studio?

Thanks

Sitansu

Here is :

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[f_getPeopleTabRowCounts] (@PeopleRSN INT, @TabMask VARCHAR(10), @UserId VARCHAR (128), @enableRLS VARCHAR (1)) 
RETURNS VARCHAR(2000) 
AS 
BEGIN 
3

There are 3 answers

0
JammoD On BEST ANSWER

Your function isn't returning a Table, so cannot be a Table Valued function, and looks much like a Scalar Valued Function.

Technet - Table Valued Functions

To test a Scalar Valued Function you should use

SELECT dbo.f_getPeopleTabRowCounts(7424,'YYYYYYYYYYYYY','abcd','Y');
0
junketsu On

you can also do declaring of the variables top side and then use 'set' to designate them with values. once your done testing comment out declare variables thru set variables sql script. Its always good to leave those in for testing purposes.

OR

like the comment before me said. Hardcode the values for each param. test and replace back with params.

0
Metaphor On

Right-click on your function and select script function as/select to/new query editor window. Then just replace the with values you want to test.