随笔分类 -  A├ SQL实例

经典提炼:一些写得比较精炼和性能好的SQL语句;或是一些难写法
错误消息为: SqlDateTime 溢出。错误:“SqlDateTime 溢出。必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM之间。”
摘要:错误消息为: SqlDateTime 溢出。错误:“SqlDateTime 溢出。必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM之间。” 阅读全文

posted @ 2011-09-04 14:03 jshchg

COMPUTE&COMPUTE...BY...(转)
摘要:SQL语句 compute 和compute by 阅读全文

posted @ 2011-07-21 22:36 jshchg

SQL 存储过程加密
摘要:sql存储过程加密对SQL存储过程加密,加密后将无法查看此存储过程的内容。建议使用前先备份。1 create proc aaaa2 with encryption ---------加密3 as 4 begin4 select 'aaa'5end 阅读全文

posted @ 2010-09-02 17:19 jshchg

SQL存储过程解密 Encrypted object is not transferable, and script can not be generated
摘要:转载至:http://www.cnblogs.com/tohen/archive/2009/03/10/1408006.html存储过程解密(破解函数,过程,触发器,视图.仅限于SQLSERVER2000) Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->/*--调用示例:--解密指定存储过程execsp_decrypt'存储过程名'--*/Code highlighting produced by Actipro CodeH 阅读全文

posted @ 2010-09-02 17:15 jshchg

经典SQL
摘要:转载至:http://www.cnblogs.com/msn/archive/2006/11/21/567951.html获取GUID:SELECTNEWID()说明:复制表(只复制结构,源表名:a新表名:b)SQL:select*intobfromawhere1<>1说明:拷贝表(拷贝数据,源表名:a目标表名:b)insertintob(a,b,c)selectd,e,ffromb;把所有姓名相同的只取出一个selecta.namefromtable_nameawherea.idin(selectb.idfromtable_namebwherea.id<>b.id)同 阅读全文

posted @ 2010-08-09 14:18 jshchg

ORDER BY 子句在视图、内嵌函数、派生表和子查询中无效(消息 1033,级别 15,状态 1)
摘要:消息 1033,级别 15,状态 1,第 5 行除非同时指定了 TOP,否则 ORDER BY 子句在视图、内嵌函数、派生表和子查询中无效。默认情况下,如果在子查询,函数,视图中尝试去使用ORDER BY,CREATE VIEW dbo.VSortedOrdersAS SELECT orderid, customerid FROM dbo.Orders ORDER BY orderid GO那么可能会遇到下面的错误消息 1033,级别 15,状态 1,第 4 行除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。原因就 阅读全文

posted @ 2010-07-10 09:39 jshchg

SQL Server 2000 数据库程序设计模拟试题
摘要:http://www.cnblogs.com/dnuace/archive/2005/12/13/296518.aspx 阅读全文

posted @ 2010-07-07 15:31 jshchg

行转列,列转行
摘要:--================== 行转列 ====================================================DROP table #studentCREATE TABLE #student (stdname nvarchar(10),stdsubject nvarchar(10),result int)INSERT INTO #student VALUES ('张三','语文',80)INSERT INTO #student values ('张三','数学',90)INSERT IN 阅读全文

posted @ 2010-06-12 18:26 jshchg

先聚合再连接
摘要:string SQL = @"select isnull(i.IntegralSum,0.0)as IntegralSum,a.AccountSum,u.UserLave,u.AddTime from Bst_User uleft join (select UserId,sum(cast(IntegralCount as numeric(10,2))) as IntegralSumfrom Bst_Integral where IsOver=0 group by UserId) ion i.UserId=u.UserIdinner join (select UserId,sum(ca 阅读全文

posted @ 2010-06-07 16:39 jshchg

导航