SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Alter function parameters then exec. in same query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chasingvertigo
Starting Member

5 Posts

Posted - 12/18/2012 :  16:31:13  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
1642 Posts

Posted - 12/18/2012 :  19:34:09  Show Profile  Reply with Quote
Could not reproduce:
--- 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;
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!

Edited by - Bustaz Kool on 12/18/2012 19:36:19
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000