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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Alter function parameters then exec. in same query

Author  Topic 

chasingvertigo
Starting Member

5 Posts

Posted - 2012-12-18 : 16:31:13
I'm writing a deployment script that I would very much prefer stay as one query, however this is causing an issue when ran.

Here's what I have:

Function FunctionName has one parameter. I run this:

ALTER FUNCTION dbo.FunctionName(p1 int, p2 int) returns BIT AS 
BEGIN
RETURN 1
END

GO

SELECT [dbo].[FunctionName] (1,2)



This gives the following error:

Procedure or function dbo.FunctionName has too many arguments specified. It appears to be evaluating whether the select will work before doing the alter. Running these as separate queries works fine. Does anyone know how to make the above work in one query?

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-12-18 : 19:34:09
Could not reproduce:[CODE]--- Ran this first
create function dbo.Junk(@x int)
returns int
as
begin
return @x;
end
go
--- Ran from here down in SSMS
alter function dbo.Junk(@x int, @y int)
returns int
as
begin
return @x + @y;
end
go
select dbo.Junk(1, 2);
go
drop function dbo.Junk;[/CODE]Runs fine in SSMS. No errors; no warnings. Are you missing the '@' as the initial character in the function parameters?

=================================================
Hear the sledges with the bells - silver bells!
What a world of merriment their melody foretells!
Go to Top of Page
   

- Advertisement -