x

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

more ▼

asked Mar 03, 2010 at 02:34 PM in Default

ibrahim khan gravatar image

ibrahim khan
12 1 3 3

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Mar 03, 2010 at 03:06 PM

Grant Fritchey gravatar image

Grant Fritchey ♦♦
103k 19 21 74

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.
Mar 03, 2010 at 04:00 PM TimothyAWiseman
(comments are locked)
10|1200 characters needed characters left
  • DDL commands are reliable commands to the user.

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

more ▼

answered Feb 20, 2012 at 06:24 AM

prasanth gravatar image

prasanth
1 1

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x33

asked: Mar 03, 2010 at 02:34 PM

Seen: 2439 times

Last Updated: Feb 20, 2012 at 06:25 AM