question

ibrahim khan avatar image
ibrahim khan asked

Use DDL Statements ?

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 ..

ddl
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered

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:

Assignment statements.

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.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TimothyAWiseman avatar image TimothyAWiseman commented ·
The rule of thumb is that a function should have no effect on the state of the database (except possibly temporary read locks of course) and only return data. DDL statements by definition are designed to change the state of the database.
1 Like 1 ·
prasanth avatar image
prasanth answered
  • DDL commands are reliable commands to the user.

  • By this commands we can create a structure of Database.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.