随笔分类 -  SQL Server

摘要:注:我是在服务器上执行的(在客户端执行,文件也是导出到服务器磁盘)。 导出:EXEC master..xp_cmdshell 'bcp "select column1,column2,.........columnN from dbname.dbo.tablename" queryout d:\da 阅读全文
posted @ 2021-06-21 11:28 吴永富 阅读(342) 评论(0) 推荐(0)
摘要:set statistics profile onset statistics io onset statistics time ongo--begin select * from ......--end set statistics profile offset sta... 阅读全文
posted @ 2014-07-21 10:48 吴永富 阅读(301) 评论(0) 推荐(0)
摘要:--将sqlserver表中的数据导出sql语句或生成insert into语句if Object_id('UspOutputData') is not null drop PROCEDURE UspOutputData;goCREATE PROCEDURE dbo.UspOutputData @tablename sysname ASBEGIN declare @column varchar(1000) declare @columndata varchar(1000) declare @sql varchar(4000) declare @xt... 阅读全文
posted @ 2013-05-25 12:31 吴永富 阅读(201) 评论(0) 推荐(0)
摘要:错误提示标题: Microsoft SQL Server Management Studio附加数据库 对于 服务器“OWEN-PC\OWEN”失败。 (Microsoft.SqlServer.Smo)执行 Transact-SQL 语句或批处理时发生了异常。 (Microsoft.SqlServer.ConnectionInfo)无法打开物理文件 "D:\SqlData\ABC2008.mdf"。操作系统错误 5:"5(拒绝访问。)"。 (Microsoft SQL Server,错误: 5120)解决办法D:\SqlData\ABC2008.mdf, 阅读全文
posted @ 2013-03-19 09:15 吴永富 阅读(1130) 评论(0) 推荐(0)
摘要:原创,转载请注明出处。//author:MeBack_黯然消魂小弟摸索了二天,终于搞定,不敢独享。第一次使用微软的SqlBulkCopy,其实它也是调用Bulk insert的,只不过微软封装了它,不过它不能指定映射文件,常出错,会说类型不匹配。一咬牙决定自己动手做。以下是具体的操作:第一步:使用Bcp工具先生成一个XML格式化文档,它能映射欲插入的数据与数据库的表的对应关系。有关Bcp工具的使用请在CMD中键入Bcp /?。 在CMD中敲入命令: bcp 数据库名.表名 format nul -c -x -f 生成文档的路径 -T 。 先存为:dataformat.xml。如果你不想自己敲, 阅读全文
posted @ 2013-03-18 14:39 吴永富 阅读(768) 评论(0) 推荐(0)