随笔分类 -  Sqlserver

"Library used incorrectly\r\nNo transaction is active on this connection
摘要:未处理 System.Data.SQLite.SQLiteException Message="Library used incorrectly\r\nNo transaction is active on this connection" StackTrace: 位于 System.Data.SQLite.SQLiteTransaction.IsValid(Boolean throwErro... 阅读全文
posted @ 2010-12-02 11:52 TsingCai 阅读(2436) 评论(1) 推荐(0)
ado.net事务
摘要:1、创建事务的结构SqlConnection sqlConnection = new SqlConnection(); ...初始化连接 // 开启事务 SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); // 将事务应用于Command SqlCommand sqlCommand = new ... 阅读全文
posted @ 2010-11-26 10:42 TsingCai 阅读(359) 评论(0) 推荐(0)
SQLServer中批量插入数据方式的性能对比 (转)
摘要:转自:http://www.cnblogs.com/wlb/archive/2010/03/02/1676136.html昨天下午快下班的时候,无意中听到公司两位同事在探讨批量向数据库插入数据的性能优化问题,顿时来了兴趣,把自己的想法向两位同事说了一下,于是有了本文。公司技术背景:数据库访问类(xxx.DataBase.Dll)调用存储过程实现数据库的访问。技术方案一:压缩时间下程序员写出的第一个... 阅读全文
posted @ 2010-10-15 23:04 TsingCai 阅读(420) 评论(0) 推荐(0)
用SQL批量插入数据(转)
摘要:作者:曾进 (qq:310575) 最近忙于公司BI软件性能测试,这几天主要测试CUBE采用ROLAP下,PA的并发和稳定性。 涉及表和维度,立方:事实表sales_fact_1997,维度表time_by_day;立方:sales 修改内容:删除原来的TIME维度,新建TIME维度,修改SALES立方。数据插入: 1,事实数据插入:通过DTS加调度实现将sales_fact_1997的数据进行复... 阅读全文
posted @ 2010-10-15 21:28 TsingCai 阅读(4120) 评论(0) 推荐(0)
sqlhelper 使用事务实例
摘要:string myConnectString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";SqlConnection myConnection = new SqlConnection(myConnectString)... 阅读全文
posted @ 2010-10-15 07:32 TsingCai 阅读(426) 评论(0) 推荐(0)
触发器的语法
摘要:DELIMITER |  CREATE TRIGGER `<databaseName>`.`<triggerName>`  < [ BEFORE | AFTER ] > < [ INSERT | UPDATE | DELETE ] >   ON <tableName>   FOR EACH ROW  BEGIN   --do someth... 阅读全文
posted @ 2010-09-08 08:35 TsingCai 阅读(204) 评论(0) 推荐(0)
复制A表到B表
摘要:1、只复制结构,不复制数据select * into B from A where 1=22、复制结构和数据select * into B from A 阅读全文
posted @ 2010-08-10 21:47 TsingCai 阅读(218) 评论(0) 推荐(0)
查找死锁的存储过程
摘要:use mastergocreate procedure sp_who_lockasbegindeclare @spid int,@bl int,@intTransactionCountOnEntry int,@intRowcount int,@intCountProperties int,@intCounter intcreate table #tmp_lock_who (id int iden... 阅读全文
posted @ 2010-08-07 11:44 TsingCai 阅读(265) 评论(0) 推荐(0)
sql2005返回记录行号
摘要:我们知道,SQL Server 2005和SQL Server 2000 相比较,SQL Server 2005有很多新特性。这篇文章我们要讨论其中的一个新函数Row_Number()。数据库管理员和开发者已经期待这个函数很久了,现在终于等到了!通常,开发者和管理员在一个查询里,用临时表和列相关的子查询来计算产生行号。现在SQL Server 2005提供了一个函数,代替所有多余的代码来产生行号。... 阅读全文
posted @ 2010-08-06 09:58 TsingCai 阅读(6894) 评论(0) 推荐(0)
金蝶KPGETSQL SQL查询语句返回空记录如何解决
摘要:方法一、select col1 from table1union select 0order by col1 desc 方法一可以用在金蝶K3自定义报表的KPGETSQL语句中方法二、if exists (select col1 from table1)select col1 from table1else select 0 阅读全文
posted @ 2010-07-15 09:47 TsingCai 阅读(1165) 评论(0) 推荐(0)