MSSQL資料庫資料匯出insert

2021-06-05 18:28:13 字數 1787 閱讀 4767

create proc spgeninsertsqlhan(@tablename varchar(256))  

as

begin

declare @sql varchar(max)

declare @sqlvalues varchar(max)

set @sql =' ('

set @sqlvalues = 'values (''+'

select @sqlvalues = @sqlvalues + cols + ' + '','' + ' ,@sql = @sql + name + ','

from

(select case

when xtype in (48,52,56,59,60,62,104,106,108,122,127)

then 'case when '+ name +' is null then ''null'' else ' + 'cast('+ name + ' as varchar)'+' end'

when xtype in (58,61)

then 'case when '+ name +' is null then ''null'' else '+''''''''' + ' + 'cast('+ name +' as varchar)'+ '+'''''''''+' end'

when xtype in (167)

then 'case when '+ name +' is null then ''null'' else '+''''''''' + ' + 'replace('+ name+','''''''','''''''''''')' + '+'''''''''+' end'

when xtype in (231)

then 'case when '+ name +' is null then ''null'' else '+'''n'''''' + ' + 'replace('+ name+','''''''','''''''''''')' + '+'''''''''+' end'

when xtype in (175)

then 'case when '+ name +' is null then ''null'' else '+''''''''' + ' + 'cast(replace('+ name+','''''''','''''''''''') as char(' + cast(length as varchar) + '))+'''''''''+' end'

when xtype in (239)

then 'case when '+ name +' is null then ''null'' else '+'''n'''''' + ' + 'cast(replace('+ name+','''''''','''''''''''') as char(' + cast(length as varchar) + '))+'''''''''+' end'

else '''null'''

end as cols,name

from syscolumns

where id = object_id(@tablename)

) tset @sql ='select ''insert into '+ @tablename + left(@sql,len(@sql)-1)+') ' + left(@sqlvalues,len(@sqlvalues)-4) + ');'' from '+@tablename

--print @sql

exec (@sql)

end

MSSQL資料庫注入

用下面的這種方法暫時解決了,目前為止沒有再出現插入了 在global.asax檔案下面加入如下 希望能管用.針對.net region sql注入式攻擊 分析 處理使用者提交的請求 分析使用者請求是否正常 傳入使用者提交資料 返回是否含有sql注入式攻擊 private bool processsq...

MSSQL資料庫使用者

1 建立登入帳戶 1 新增 windows 登入帳戶 exec sp grantlogin jbtraining s26301 網域名稱 使用者名稱 2 新增 sql 登入帳戶 exec sp addlogin zhangsan 1234 exec 表示呼叫儲存過程,儲存過程類似 c 語言的函式。內...

MSSQL資料庫同步

mssql資料同步利用資料庫複製技術實現資料同步更新 來自網路,也是非常完美的教程 複製的概念 複製是將一組資料從乙個資料來源拷貝到多個資料來源的技術,是將乙份資料發布到多個儲存站點上的有效方式。使用複製技術,使用者可以將乙份資料發布到多台伺服器 上,從而使不同的伺服器使用者都可以在許可權的許可的範...