Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSmakeviewproc

  No additional text.


Syntax
create procedure sys.sp_MSmakeviewproc (
    @viewname sysname,
    @ownername sysname,
    @procname sysname,
    @rgcol sysname,
    @pubid uniqueidentifier,
    @artid uniqueidentifier
)
as
begin
    declare @retcode            smallint
    declare @command            nvarchar(4000)
    declare @db_name            sysname
	declare @quoted_procname	nvarchar(258)
    set nocount on

    select @retcode = 0
    select @db_name = db_name()

    if @@error <> 0 or @retcode <> 0
    begin
        select @retcode = 1
        goto Failure
    end

    -- drop if there is a proc already by the same name
    if object_id(@procname) is not NULL
    begin
		select @command = 'drop procedure ' + quotename(@procname)
        exec (@command)
        if @@error<>0
            goto Failure
    end

    select @command = N'exec ' + quotename(@db_name) + '.sys.sp_MSscriptviewproc
        @viewname = ' + fn_replmakestringliteral(@viewname) collate database_default + ',
        @ownername = ' + fn_replmakestringliteral(@ownername) collate database_default + ',
        @procname = ' + fn_replmakestringliteral(@procname) collate database_default + ',
        @rgcol = ' + fn_replmakestringliteral(@rgcol) collate database_default + ',
        @pubid = ''' + convert(nvarchar(40), @pubid) + ''',
        @artid = ''' + convert(nvarchar(40), @artid) + ''''
    if @@error <> 0 or @retcode <> 0
    begin
        select @retcode = 1
        goto Failure
    end

    exec @retcode = sys.sp_execresultset_nvarcharmaxrows @command

    if @@error <> 0 or @retcode <> 0
    begin
        select @retcode = 1
        goto Failure
    end

    select @quoted_procname=QUOTENAME(@procname)
    exec @retcode = sys.sp_MS_marksystemobject @quoted_procname
    if @@error <> 0 or @retcode <> 0
    begin
        select @retcode = 1
        goto Failure
    end

    exec ('grant exec on ' + @quoted_procname + ' to public')
    if @@error <> 0 or @retcode <> 0
    begin
        select @retcode = 1
        goto Failure
    end

Failure:
    return @retcode
end

 
Last revision 2008RTM
See also

  sp_MScreateandsetarticleprocs (Procedure)
sp_MSdrop_rlrecon (Procedure)
sp_MSpublicationview (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