Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

T-SQL(MS SQL 2008), Executing procedure without 'EXEC' or 'EXECUTE' word

Is it OK to execute a stored procedure without 'EXEC' or 'EXECUTE' word in the beginning ?

Normally to execute stored procedure I do

EXEC DeleteProfile 'Joe Smith'

But, I've noticed that next command works as well:

DeleteProfile 'Joe Smith'

Why should I write 'EXEC' or 'EXECUTE' word?

Is it ok not to write it before stored procedure name to execute stored procedure?

Thanks.

like image 382
Aremyst Avatar asked Dec 18 '12 06:12

Aremyst


People also ask

How do I run a stored procedure manually?

Expand the database that you want, expand Programmability, and then expand Stored Procedures. Right-click the user-defined stored procedure that you want and select Execute Stored Procedure.

Can we execute procedure in select statement?

You cannot call a procedure in a select statement, because it does not return anything.

What is the command to execute stored procedure in SQL?

The EXEC command is used to execute a stored procedure, or a SQL string passed to it. You can also use full command EXECUTE which is the same as EXEC.


1 Answers

I've found in MSDN "You do not have to specify the EXECUTE keyword when you execute stored procedures when the statement is the first one in a batch."

Get it. Sorry for question.

This wouldn't work without GO at the end of each statement:

DeleteProfile 'Joe Smith'
DeleteProfile 'Joe Smith'
DeleteProfile 'Joe Smith'
like image 76
Aremyst Avatar answered Oct 06 '22 02:10

Aremyst