Hi Guys,
I have a published server.
Where i'm write a function which returns a table using Exec query.
But Unfortunately i'm getting error
Msg 443, Level 16, State 14, Procedure Fn_GetDailyRentalFullDataForView, Line 15
Invalid use of a side-effecting operator 'INSERT EXEC' within a function.
Msg 444, Level 16, State 2, Procedure Fn_GetDailyRentalFullDataForView, Line 18
Select statements included within a function cannot return data to a client.
Msg 455, Level 16, State 2, Procedure Fn_GetDailyRentalFullDataForView, Line 18
The last statement included within a function must be a return statement.
What I have tried:
Create Function Fn_GetDailyRentalFullDataForView()
Returns @t table(
[VehicleType] [int] NULL,
[vt] [nvarchar](50) NULL,
[TruckTotal] [nvarchar](50) NULL,
[Description] [nvarchar](max) NULL,
[Driver] [nvarchar](50) NULL,
[Location] [nvarchar](250) NULL,
[Department] [nvarchar](50) NULL,
[JobDate] [date] NULL
)
as
begin
insert into @t
exec Sp_GetDailyRentalFullDataForView
select * from @t
end
This is my Function.
Please let me know, where i'm getting wrong.
Thanks