I decided to edit my post since people didn't quite get what I'm trying to do (I suppose it was not irrelevant to say why I needed it after all):
Ok, there we go. The thing is, I have a HUGE SQL script which many clients use and it has to be ran thoroughly every time a client executes the "database management" functionality that our software provides. So some of these clients might already have the procedure stored upon running the script, and some may not. I know this is stupid, I don't actually need this procedure to remain unstored, I can just check if it exists and create it if it doesn't. However, it doesn't matter how much I try to bend T-SQL syntax, there's always an error (always related to the fact that "CREATE/ALTER PROCEDURE' must be the first statement in a query batch"). That's why I came up with the drop before create thing. And I read around the web that it's the only way to do it, but I don't like the way it's done (suppose that should have been my post in the first place).
Original Post:
Hello. After some research, I found info only regarding PL/SQL on the matter, but what is proposed there doesn't work with T-SQL. I think it's irrelevant to point out why I need a non-stored procedure so you'll just gonna have to take my word when I say that I do. For now, I'm doing this:
IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'MyProc')
DROP PROCEDURE MyProc
GO
CREATE PROCEDURE MyProc
...
It works, but I wanted to know if there's a more effective/elegant way to do it?