Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 A simple Function

Author  Topic 

Alaveh
Starting Member

24 Posts

Posted - 2011-09-29 : 19:02:17
hi

why my function doesn't works .

either function and main sql works alone but doesn't works together .

CREATE FUNCTION sad() RETURNS INT
AS
BEGIN
RETURN 100;
end ;

select
1100-sad()

tduggan
Starting Member

26 Posts

Posted - 2011-09-29 : 19:06:12
You are trying to pass in a parameter value, but your function doesn't accept any parameters.
Go to Top of Page

Alaveh
Starting Member

24 Posts

Posted - 2011-09-29 : 19:10:21
sorry ,,,, my mistake ,,, no i don't pass any thing . i edit my first post ,,, now try answer me please . thank you
Go to Top of Page

tduggan
Starting Member

26 Posts

Posted - 2011-09-29 : 19:12:20
You need to specify the function's owner, probably dbo:

select
1100-dbo.sad()
Go to Top of Page

tduggan
Starting Member

26 Posts

Posted - 2011-09-29 : 19:12:55
CREATE FUNCTION sad() RETURNS INT
AS
BEGIN
RETURN 100;
end ;
GO
select
1100-dbo.sad()
Go to Top of Page

Alaveh
Starting Member

24 Posts

Posted - 2011-09-29 : 19:17:03
thank you tduggan ,,, it works :)

i didn't wrote GO after end .

thanks again
Go to Top of Page

tduggan
Starting Member

26 Posts

Posted - 2011-09-29 : 19:18:28
You're welcome, glad to help.
Go to Top of Page
   

- Advertisement -