how to use ddl statements in functions and is there any limitation to use ddl statements,means we can use some no of ddl statements. plaese tell me in procedure also.help me to get out this question ..
asked Mar 03 '10 at 02:34 PM in Default
Is the question then, can you use DDL statements within user defined functions? If so, the answer is no. You can't use DDL statements within UDFs. From the books online, these are the valid types of statements:
The following statements are valid in a function:
Control-of-Flow statements except TRY...CATCH statements.
DECLARE statements defining local data variables and local cursors.
SELECT statements that contain select lists with expressions that assign values to local variables.
Cursor operations referencing local cursors that are declared, opened, closed, and deallocated in the function. Only FETCH statements that assign values to local variables using the INTO clause are allowed; FETCH statements that return data to the client are not allowed.
INSERT, UPDATE, and DELETE statements modifying local table variables.
EXECUTE statements calling extended stored procedures.
answered Mar 03 '10 at 03:06 PM
Grant Fritchey ♦♦