create proc dataexport
@tablename varchar(100)
asbegin
declare @columnnamelist nvarchar(4000)
declare @columnvaluelist nvarchar(4000)
set @columnnamelist=''
set @columnvaluelist=''
declare @object_id int
select @object_id=object_id from sys.objects where name=@tablename and type='u'
declare mycursor cursor for --定義游標
select name from sys.columns where object_id=@object_id order by column_id --設定游標遍歷的資料集
open mycursor --開啟游標
declare @name varchar(50)
fetch next from mycursor into @name --移動游標,並給變數填充資料
while @@fetch_status=0
begin
if @columnnamelist<>''
begin
set @columnnamelist=@columnnamelist+','
set @columnvaluelist=@columnvaluelist+','
endset @columnnamelist=@columnnamelist+@name
set @columnvaluelist=@columnvaluelist+'###+isnull(convert(varchar,'+@name+'),#null#)+###'
fetch next from mycursor into @name --移動游標,並填充變數資料
endclose mycursor --關閉游標
deallocate mycursor --銷毀游標
declare @sql nvarchar(4000)
set @sql='select #insert '+@tablename+'('+@columnnamelist+') values('+@columnvaluelist+')# from '+@tablename
set @sql=replace(@sql,'#','''')
set @sql='select ''set identity_insert '+@tablename+' on'' union all ' +@sql+' union all select ''set identity_insert '+@tablename+' off'''
exec sp_executesql @sql
end生成的sql語句中,將'null'替換為null
生成資料庫字典SQL
select 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end,字段序號 a.colorder,欄位名 a.name,標識 case when ...
pb根據sql語句生成資料視窗
string ls sql,ls syntax,ls error ls sql mle 1.text ls syntax sqlca.syntaxfromsql ls sql,style type grid ls error if len ls error 0 then messagebox err...
TPC DS 生成資料
其實,使用 tpc ds 生成系統效能測試的資料,說簡單也簡單,說難,確實也不好做!關鍵是在每一步的操作中,如果遇到了問題,該怎麼樣處理,這個是個問題的關鍵。下面就將生成的步驟簡單描述一下,好記性不如爛筆頭呀!通過以上六步驟,就可以將 tpc ds 資料全部 load 到對應的表中去,也就生成了相應...