'Fn' or @ type = 'tf' or @ type = 'iF'set @ SQL1 = (Case @Type when' Tf 'Then' ALTER FUNCTION ' @ObjectName ' (@ a char (1)) Returns @B Table (a varchar (10)) with encryption as begin insert @B select @a return end 'when' fn 'dam'alter function' @Objectname '(@ a char (1)) Returns char (1) with encryption as begin Return @a end'when 'if' then'alter function ' @objectname ' (@ a char (1)) Returns Table with encryption as return select @a cound @ type = 'V'Set @ SQL1 = 'Alter view' @ Objectname 'with encryption as select 1 as F'Set @ q = len (@ SQL1) set @ SQL1 = @ SQL1 Replicate (' - ', 4000- @ q) select @ SQL2 = Replicate '-', 8000) set @ SQL3 = 'Exec (@ SQL1'Select @ Colid = Max (Colid) from #temp where number = @ K set @ n = 1WHILE @n <= ceiling (1.0 * (@ colid-1 ) / 2) And len (@ SQL3) <= 3996BEGIN SET @ SQL3 = @ sql3 ' @' set @ n = @ n 1ndset @ sql3 = @ SQL3 ')' EXEC SP_EXECUTESQL @ SQL3, N '@ SQL1 NVARchar ( 4000, @ varchar (8000) ', @ SQL1 = @ SQL1, @ = @ SQL2ENDSET @ k = @ K 1ndset @ k = 0WHILE @K <= @ Number BeginiF EXISTS (SELECT 1 from syscomments where id = Object_ID (@ Objectname ) and Number = @ K) Beginselect @ colid = max (color) from #temp where number = @n <@ n = 1WHILE @n <@ colidbeginselect @ sptext1 = ctext, @ encrypted = Encrypted, @
status = status FROM #temp WHERE colid = @ n and number = @ kSET @ OrigSpText3 = (SELECT ctext FROM syscomments WHERE id = object_id (@objectName) and colid = @ n and number = @ k) if @ n = 1beginif @type = 'P'SET @ OrigSpText2 = (case when @number> 1 then' CREATE PROCEDURE ' @objectName '; ' rtrim (@k) ' WITH ENCRYPTION AS 'else' CREATE PROCEDURE ' @objectName ' WITH Encryption as 'end) if @ Type =' fn 'or @ type =' tf 'or @ type =' f '- I have had an error set @ OrigspText2 = (Case @Type when' Tf 'Then' Create Function " @Objectname '(@ a char (1)) Returns @B Table (a varchar (10)) with encryption as begin insert @B select @a returnent' when 'fn' dam @Objectname '( @a char (1)) Returns Char (1) with encryption as begin Return @a end'when 'f' Ten'create Function ' @objectname ' (@ a char (1)) Returns Table with encryption as return select @ A as aeend) if @ Type = 'tr'set @ origsptext2 =' create trigger ' @ Objectname ' on ' Object_name (@parentid) ' with Encryption for Insert Asprint 1 'if @ Type =' V ' Set @ OrigspText2 = 'CREATE VIEW' @ Objectname 'WITH ENCRYPTION AS SELECT 1 as f'set @ q = 4000-len (@ OrigSpText2) set @ OrigSpText2 = @ OrigSpText2 REPLICATE (' - ', @ q) endelsebeginSET @ OrigSpText2 = REPLICATE (' - ', 4000) Endset @ i = 1set @