<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[txlicenhe的专栏]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/txlicenhe</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; txlicenhe]]></copyright><item><title><![CDATA[自已动手记录SQL Server的Log]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/1756909</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/1756909</guid><author>txlicenhe</author><pubDate>Fri, 24 Aug 2007 08:19:00 +0800</pubDate><description><![CDATA[/*建一个记录触发触发器的表，也可以说就是自己的Log吧*/create table  tbLog(  EventType nvarchar(30),   Parameters Int,  EventInfo nvarchar(255))go/*建一个表，并加入三笔数据，作为测试用的表*/Create table tbA(aa int,bb int)insert tbA values(1,1)]]></description><category></category></item><item><title><![CDATA[灵活设置规则]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/437471</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/437471</guid><author>txlicenhe</author><pubDate>Thu, 28 Jul 2005 15:21:00 +0800</pubDate><description><![CDATA[/* 刚写了一个灵活设置默认值的，再来一个灵活设置规则的，其实基本上是一样的。 参考联机帮助：　Create rule; sp_bindrule; sp_unbindrule 下面是测试: */ /*创建一个测试用表*/ create table test_tb(id int ,Country varchar(10)) --没有绑定Rule时全部insert成功 insert test_tb va]]></description><category></category></item><item><title><![CDATA[灵活设置默认值]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/437231</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/437231</guid><author>txlicenhe</author><pubDate>Thu, 28 Jul 2005 10:57:00 +0800</pubDate><description><![CDATA[/*在建表时一般会设置默认值，但如果默认值随着条件的变化有可能更改，比如录入员工资料时默认工资为500，下一年度涨工资后默认工资为600。或者有很多表中的很多列有相同的默认值时，可以考虑用一个变量来设置，就要自定义数据类型一样。SQL提供有这方面的功能，就是Create Default。参考联机帮助：　Create Default;  sp_bindefault;  sp_unbindefault]]></description><category></category></item><item><title><![CDATA[SQL邮件自动应答(根据收到的邮件中的查询语句回复语句执行结果)]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21044</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21044</guid><author>txlicenhe</author><pubDate>Wed, 19 May 2004 13:38:00 +0800</pubDate><description><![CDATA[SQLMail可以收发邮件，可能好多人都有xp_sendmail发送过邮件，这里介绍一种邮件服务器接收邮件后，根据邮件内容(只能是查询语句)把邮件中的查询语句执行后的结果以附件形式自动返回给发送邮件者。eg: 发送邮件，邮件内容为: select top 10 id,name from sysobjects则服务器自动回复邮件，内容为上述查询语句的执行结果，以附件形式发送。1:当然是先配置]]></description><category></category></item><item><title><![CDATA[外键开关]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21043</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21043</guid><author>txlicenhe</author><pubDate>Thu, 22 Apr 2004 14:34:00 +0800</pubDate><description><![CDATA[最近在做假资料时经常需要删除一些表中的内容。但是：设置外键后，想删除表中的数据无法删除，这时需删除外键后重建，或找到外键后用 alter table 表名 nocheck 外键名　来暂时屏蔽外键，然后删除。干脆写个存储过程，设置外键的开关。exec fk_switch 表名,0 屏蔽外键exec fk_switch 表名,1 重启外键/* Usage:exec fk_switch ]]></description><category></category></item><item><title><![CDATA[在视图中用order by]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21042</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21042</guid><author>txlicenhe</author><pubDate>Sun, 21 Mar 2004 17:30:00 +0800</pubDate><description><![CDATA[大家知道1：如下查询语句没问题  select * from sysobjects order by name2：如果把该查询语句建成视图  create view v_test  as  select * from sysobjects order by name  会提示出错:The ORDER BY clause is invalid in views, inline functions]]></description><category></category></item><item><title><![CDATA[找SQL表的主键]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21040</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21040</guid><author>txlicenhe</author><pubDate>Sat, 20 Mar 2004 15:04:00 +0800</pubDate><description><![CDATA[1:利用SQL自带的存储过程EXEC sp_pkeys @table_name=表名2:利用系统表INFORMATION_SCHEMA.KEY_COLUMN_USAGE SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME=表名3: 以下这个查询表结构的]]></description><category></category></item><item><title><![CDATA[对所有表进行类似处理]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21041</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21041</guid><author>txlicenhe</author><pubDate>Thu, 26 Feb 2004 14:36:00 +0800</pubDate><description><![CDATA[eg1:大家知道，如果将一个表所有者改为dbo，只需sp_changeobjectowner 表名,dbo即可但要将所有的表的所有者都改为dbo,可以用循环处理，此处略其实用SQL的系统存储过程sp_MSForEachTable可以轻松搞定只需exec sp_MSForEachTable sp_changeobjectowner ?, dbo当然]]></description><category></category></item><item><title><![CDATA[text字段]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21033</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21033</guid><author>txlicenhe</author><pubDate>Tue, 27 Jan 2004 21:06:00 +0800</pubDate><description><![CDATA[支持text字段处理的仅有:下面的函数和语句可以与 ntext、text 或 image 数据一起使用。函数          语句 DATALENGTH    READTEXT PATINDEX      SET TEXTSIZE SUBSTRING     UPDATETEXT TEXTPTR       WRITETEXT TEXTVALID 1:替换--创建数据测试环境create]]></description><category></category></item><item><title><![CDATA[行列转换  交叉表]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21032</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21032</guid><author>txlicenhe</author><pubDate>Tue, 27 Jan 2004 21:06:00 +0800</pubDate><description><![CDATA[总结了一些有代表性的贴子，具体见http://expert.youkuaiyun.com/Expert/topic/2440/2440306.xml?temp=.69416451: 列转为行:eg1:Create table test (name char(10),km char(10),cj int)goinsert test values(张三,语文,80)insert test values]]></description><category></category></item><item><title><![CDATA[SQL中两台服务器间使用连接服务器]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21037</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21037</guid><author>txlicenhe</author><pubDate>Thu, 08 Jan 2004 13:58:00 +0800</pubDate><description><![CDATA[1：执行另一服务器上的存储过程exec OPENDATASOURCE(         SQLOLEDB,         Data Source=远程ip;User ID=sa;Password=密码         ).库名.dbo.存储过程名2：将资料插入另一服务器上的表中select * into 本地库名..表名 from OPENDATASOURCE(       ]]></description><category></category></item><item><title><![CDATA[通用工资计税方案]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21039</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21039</guid><author>txlicenhe</author><pubDate>Tue, 06 Jan 2004 10:07:00 +0800</pubDate><description><![CDATA[--1:计税方案表create table  skm_mstr(序号 int,工资比例 int,始 int, 止 int,税率 int,速算值 int )/*以下数据为深圳龙岗台资企业计税方式：(比如工资为4000的计税方式为：4000*87/100 = 3840, 在2100-3599之间，适用于第3条则计算公式为 (4000*87/100-2100)*10/100 + 25 = 163  )*]]></description><category></category></item><item><title><![CDATA[ERP系统中与BOM有关的常用方法]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21036</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21036</guid><author>txlicenhe</author><pubDate>Wed, 31 Dec 2003 10:14:00 +0800</pubDate><description><![CDATA[一: BOM展开(按任一父结点展开到最底层)以下写一个简单的，视具体要求稍做修改即可。create table 表(levelid int,levelname char(2),parent int)insert 表 select  1,        AA     ,    0union all select  2 ,       BB    ,     1union all select]]></description><category></category></item><item><title><![CDATA[SQL中与IP相关的常见问题]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21035</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21035</guid><author>txlicenhe</author><pubDate>Wed, 31 Dec 2003 10:14:00 +0800</pubDate><description><![CDATA[1:得到客户端的IP地址/************* IP  **************/declare @ip varchar(20),@hst varchar(20),@sql varchar(100)declare @str varchar(100)set @str=PING +Host_Name()create table #tmp(aa varchar(200))insert #t]]></description><category></category></item><item><title><![CDATA[一个简单的考勤系统]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21034</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21034</guid><author>txlicenhe</author><pubDate>Mon, 15 Dec 2003 01:28:00 +0800</pubDate><description><![CDATA[不考虑加班，请假，外出之类。原始记录表:1：工作日历表calendar2：排班表worktime3：人事资料表employee4：异常类别表(迟到，早退，无刷卡...)abnormity5：考勤记录表timecard处理结果表：(可以用表或视图的形式存放)1: 打卡异常         10001   20031102   上午上班   迟到2：考勤明细表1：    10001   200]]></description><category></category></item><item><title><![CDATA[SQL语句导入导出大全]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21031</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21031</guid><author>txlicenhe</author><pubDate>Mon, 15 Dec 2003 01:27:00 +0800</pubDate><description><![CDATA[/*******  导出到excelEXEC master..xp_cmdshell bcp SettleDB.dbo.shanghu out c:/temp1.xls -c -q -S"GNETDATA/GNETDATA" -U"sa" -P""/***********  导入ExcelSELECT * FROM OpenDataSource( Microsoft.Jet.OLEDB.]]></description><category></category></item><item><title><![CDATA[业务单号自动增长的处理办法]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21029</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21029</guid><author>txlicenhe</author><pubDate>Mon, 15 Dec 2003 01:27:00 +0800</pubDate><description><![CDATA[问题：在实际业务处理中有些单号需要自动增长，但又不能用自增列代替      eg:  P031106001   -- 第一位P表示采购单,031106表示日期，后三位是流水号。　/* 1:创建测试用的表结构 */create table tablename(pono char(10),b int)go/* 2:创建一个得到当前日期的视图，为下面的自字义函数作准备 */create view v]]></description><category></category></item><item><title><![CDATA[动态SQL语句]]></title><link>https://blog.youkuaiyun.com/txlicenhe/article/details/21030</link><guid>https://blog.youkuaiyun.com/txlicenhe/article/details/21030</guid><author>txlicenhe</author><pubDate>Mon, 15 Dec 2003 01:26:00 +0800</pubDate><description><![CDATA[1:普通SQL语句可以用Exec执行eg:   Select * from tableName      Exec(select * from tableName)      sp_executesql Nselect * from tableName    -- 请注意字符串前一定要加N2:字段名，表名，数据库名之类作为变量时，必须用动态SQLeg:   declare @fname]]></description><category></category></item></channel></rss>