PRINT @sql
print @sample
print @tbl
EXEC SP_EXECUTESQL @sql,N''''@sample nvarchar(30) OUTPUT'''',@sample OUTPUT
INSERT INTO #tc SELECT *,ltrim(ISNULL(@maxlen,0)) as MaxLenUsed,
convert(nchar(20),ltrim(ISNULL(@sample,'''' ''''))) as Sample,'''' '''' Comment FROM #t where TableName=@tbl and FieldName=@fld
END
FETCH NEXT FROM read_cursor INTO @tbl,@fld
CLOSE read_cursor
DEALLOCATE read_cursor
GO
SET ANSI_NULLS ON
SET NOCOUNT OFF
select count(*) from #t
DROP TABLE #t
select count(*)-1 from #tc
select * into ##tx from #tc order by tablename
DROP TABLE #tc
--select * from ##tx
declare @db nvarchar(60),@sql nvarchar(3000)
set @db=db_name()
--请修改用户名和口令 导出到Excel 中
set @sql=''''exec master.dbo.xp_cmdshell ''''''''bcp ..dbo.##tx out c:\''''+@db+''''_exp.xls -w -C936 -Usa -Psa ''''''''''''
print @sql
exec(@sql)
DROP TABLE ##tx
-- ======================================================
--根据表中数据生成insert语句的存储过程
--建立存储过程,执行 spGenInsertSQL 表名
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18