Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSrestoresavedforeignkeyextendedproperties

  No additional text.


Syntax
create procedure sys.sp_MSrestoresavedforeignkeyextendedproperties (
    @program_name       sysname,
    @constraint_name    sysname,
    @parent_schema      sysname,
    @parent_name        sysname
    )
as
begin
    set nocount on
    declare @retcode int,
            @transaction_opened bit,
            @cursor_allocated bit,
            @cursor_opened bit,
            @property_name sysname,
            @property_value sql_variant

    select @retcode = 0,
           @transaction_opened = 0,
           @cursor_allocated = 0,
           @cursor_opened = 0

    begin transaction
    save transaction restoreextendedproperties
    set @transaction_opened = 1

    declare hExtendedProperties cursor local for
     select property_name, property_value
       from dbo.MSsavedforeignkeyextendedproperties
      where program_name = @program_name
        and constraint_name = @constraint_name
        and parent_schema = @parent_schema
    if @@error <> 0 or @retcode <> 0 begin set @retcode = 1 goto Failure end
    set @cursor_allocated = 1

    open hExtendedProperties
    if @@error <> 0 or @retcode <> 0 begin set @retcode = 1 goto Failure end
    set @cursor_opened = 1

    fetch hExtendedProperties into @property_name, @property_value
    while (@@fetch_status <> -1)
    begin
        execute @retcode = sys.sp_addextendedproperty @name = @property_name, @value = @property_value, @level0type = 'schema', @level0name = @parent_schema, @level1type = 'table', @level1name = @parent_name, @level2type = 'constraint', @level2name = @con
straint_name
        if @@error <> 0 or @retcode <> 0 begin set @retcode = 1 goto Failure end
        fetch hExtendedProperties into @property_name, @property_value
    end

    close hExtendedProperties
    if @@error <> 0 or @retcode <> 0 begin set @retcode = 1 goto Failure end
    set @cursor_opened = 0

    deallocate hExtendedProperties
    if @@error <> 0 or @retcode <> 0 begin set @retcode = 1 goto Failure end
    set @cursor_allocated = 0

    commit transaction
    set @transaction_opened = 0

Failure:
    if @cursor_opened = 1
    begin
        close hExtendedProperties
    end

    if @cursor_allocated = 1
    begin
        deallocate hExtendedProperties
    end

    if @transaction_opened = 1
    begin
        rollback transaction restoreextendedproperties
        commit transaction
    end

    return @retcode
end

 
Last revision 2008RTM
See also

  sp_MSrestoresavedforeignkeys (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash