SQL Server encryption with stored procedure -




i trying encrypt multiple column. need code. it's crashing @ cursor statement.

alter procedure [dbo].[encrypt] (@stringtosplit nvarchar(500)) begin     set nocount on;  declare @splitword nvarchar(255)     declare @pos  int declare @tablename nvarchar (255) declare @columnname  nvarchar (255) declare @sqlqueryforencryption nvarchar(500)  declare @enckey nvarchar(255)      declare cursorsplit cursor select @splitword dbo.splitstring (@stringtosplit)            open cursorsplit          fetch next cursorsplit         @splitword           select @pos = charindex('.', @splitword)         select @tablename = substring( @splitword, 1, @pos-1 )         set @columnname = substring(@splitword,@pos,len(@splitword)-len(@tablename))          set @enckey = key_guid('enc_sym_key')           open symmetric key enc_sym_key  decryption certificate enc_cert              set @sqlqueryforencryption = 'update' + @tablename + 'set'+ '' + @columnname +''+'= encryprtbykey key_guid'+ @enckey + ',' +@columnname               execute (@sqlqueryforencryption)           close symmetric key enc_sym_key;          fetch next cursorsplit          close cursorsplit2 deallocate cursorsplit2       close cursorsplit deallocate cursorsplit  end    alter function [dbo].[splitstring] ( @stringtosplit varchar(max) ) returns  @returnlist table ([splitword] [nvarchar] (500)) begin   declare @fullword nvarchar(255)  declare @pos int   while charindex(';' , @stringtosplit) > 0  begin   select @pos  = charindex(';', @stringtosplit)     select @fullword = substring(@stringtosplit, 1, @pos-1)    insert @returnlist    select @fullword    select @stringtosplit = substring(@stringtosplit, @pos+1, len(@stringtosplit)-@pos)  end   insert @returnlist  select @stringtosplit    return end 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -