MSSQL中计算两个日期之间相隔 xx天xx小时xx分xx秒
DECLARE @dt1 AS datetime, @dt2 AS datetime;
SELECT @dt1 = '2008-8-4 9:36:41', @dt2 = '2008-8-2 9:33:39';
DECLARE @Days AS int, @Hours AS int, @Minutes AS int, @Seconds AS int;
SET @Seconds = DATEDIFF( second, @dt2, @dt1);
SET @Days = @Seconds / (24 * 60 * 60)
SET @Seconds = @Seconds - @Days * 24 * 60 * 60
SET @Hours = @Seconds / (60 * 60);
SET @Seconds = @Seconds - @Hours * 60 * 60
SET @Minutes = @Seconds / 60;
SET @Seconds = @Seconds - @Minutes * 60;
SELECT CONVERT(varchar(10), @Days ) + '天'
+ CONVERT(varchar(10), @Hours ) + '小时'
+ CONVERT(varchar(10), @Minutes ) + '分'
+ CONVERT(varchar(10), @Seconds ) + '秒';
相关文档:
1.
--将汉字转换为拼音首字母
CREATE function GetAllPY(@str nvarchar(4000))
returns nvarchar(4000)
--WITH ENCRYPTION
as
begin
declare @intLen int
declare @strRet nvarchar(4000)
declare @temp nvarchar(100)
set @intLen &nb ......
How is MSSQL using memory?
http://www.sqlhacks.com/Administration/Memory-Usage
Memory is one the most important factor affecting MSSQL performance.
As an administrator, you should be monitoring the memory
regularly. When Microsoft SQL Server runs out of memory, it will use
virtual memory: ie: ......
--此代码实现SQL数据库远程备份,放到作业里面执行可以自动备份数据库、自动删除@keepNDays天前备份。
--此代码将本地所有的用户数据库备份到共享目录“\\backupServerIp\ShareName\数据库备份”下。
--并删除天前的备份文件。要备份成功必须能够对共享目录有操作权限!
sp_configure 'xp_cmdshell',1 ......
最近有个小东西要查看mssql数据库是用php实现的,以前我用php5.2时感觉挺简单的所以想php5.3也应该很简单的
为什么要用php5.3呢因为我想用sqlite3.0的啊,因为php5.2的不支持sqlite3.0的啊,所以我特意去下了5.3了下载回来了才发现5.3里没有mssql的dll扩展了,郁闷啊,不管这么多先用起那sqlite3.0再说了
sqlite3.0的部分 ......