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 ..
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.
DDL commands are reliable commands to the user.
By this commands we can create a structure of Database.
1 Person is following this question.