Export (0) Print
Expand All

Copying Stored Procedures and User-Defined Functions

Visual Studio .NET 2003

You can copy stored procedures and user-defined functions as the first step in creating a new SQL routine for your database. Because both stored procedures and user-defined functions must have names that are unique, the copied SQL routine is saved using the new name that you provide.

To copy a stored procedure

  1. Open the stored procedure you want to copy in the text editor.

    The stored procedure name is typically in the first line of the editor. For example, in the following line of SQL syntax, the procedure name is reptto.

    CREATE PROCEDURE reptto @lolimit money, @hilimit money
    
  2. Change the name of the stored procedure. For example, type the new name as reptto1.
    CREATE PROCEDURE reptto1 @lolimit money, @hilimit money
    
  3. Save the stored procedure to the database.

    The stored procedure is added to the Stored Procedures folder with the name you specified. The original stored procedure is not removed.

    Note   This process does not copy any privileges that may have been associated with the original stored procedure.

To copy a user-defined function

  1. Open the function you want to copy in the text editor.

    The function name is typically in the first line of the editor. For example, in the following line of SQL syntax, the function name is CubeIt.

    CREATE FUNCTION CubeIt
    
  2. Change the name of the function. For example, type the new name as my_CubeIt.
    CREATE FUNCTION my_CubeIt
    
  3. Save the function to the database.

    The newly named function is added to the Functions folder with the name you specified. The original function is not removed.

    Note   This process does not copy any privileges that may have been associated with the original function.

See Also

Working with Stored Procedures and User-Defined Functions

Show:
© 2014 Microsoft