calling stored procedure from function generates error

I have the following function:

CREATE FUNCTION dbo.test1 ()  
RETURNS  Int  AS  
BEGIN

exec test

return 3
END


The stored procedure test is as follows

select    *
From Customers
WHERE     (CustomerID = 'ALFKI')

and running the function produces the following error:

Server: Msg 557, Level 16, State 2, Procedure test, Line 5
Only functions and extended stored procedures can be executed from within a function.

Since test does not modify anything, why is this error message generated?
dotnet22Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
That doesn't matter. Check the syntax (including the notes about limitations) of the stored functions which clearly states (the same as your error message) that you cannot use stored procedures inside of UDF.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
What exactly are you trying to achieve?
---> let's find a solution !
dotnet22Author Commented:
I was learing about functions, so just wanted to test something....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.