DataBase
SQL Server,Oracle,MySQL,Sysbase
数据库 可疑 解决方法      摘要: USE MASTER GO SP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE GO ALTER DATABASE MyDB SET EMERGENCY GO sp_dboption 'MyDB', 'single user', 'true' GO DBCC CHECKDB('MyDB','REPAIR_ALLOW_DATA_LOSS') GO ALTER DATABASE MyDB SET ONLINE GO sp_configure 'allow updates', 0 reconfigure with override GO sp_dboption 'MyDB', 'single user', 'false' GO   阅读全文
posted @ 2008-12-06 15:42 阿米 阅读(58) | 评论 (0)  编辑
查询ms sql 2005版本号      摘要: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')   阅读全文
posted @ 2008-12-04 14:49 阿米 阅读(139) | 评论 (0)  编辑
查询重复记录数
posted @ 2007-12-15 22:46 阿米 阅读(164) | 评论 (0)  编辑
清数据库日志      摘要: backup log htpec3 with no_log
dbcc shrinkdatabase('htpec3')  阅读全文
posted @ 2007-09-10 10:52 阿米 阅读(127) | 评论 (0)  编辑
维护Sql Server中表的索引      摘要: 维护Sql Server中表的索引
--第一步:查看是否需要维护,查看扫描密度/Scan Density是否为100%
declare @table_id int
set @table_id=object_id('表名')
dbcc showcontig(@table_id)

--第二步:重构表索引
dbcc dbreindex('表名',pk_索引名,100)

--重做第一步,如发现扫描密度/Scan Density还是小于100%则重构表的所有索引
--并不一定能达100%。
dbcc dbreindex('表名','',100)  阅读全文
posted @ 2007-08-10 13:08 阿米 阅读(125) | 评论 (0)  编辑
sql server不存在或访问被拒绝      摘要: 问题出现在五一,真是休假睡懒觉的时候,突然接到客户的电话说网页打不开。
事情是这样的,五一前期我完成了一个客户的分析系统,用.net+sql server,在公司测试没有任何问题。于是我认为万无一失,在4月30日把系统装入客户的笔记本交付使用了。结果五一出现了上述问题。通过电话沟通我没有找到问题的原因,于是建议他连上网络试一试,客户接上了一个集线器后果然就可以使用了。
今天拿回笔记本电脑,终于找到了问题的原因,我没有给sql2000打sp3补丁(听说打sp4都不行),打上sp3后断了网也照样用。
记下这个问题,也许有人会出现我同样的问题哦!!!
  阅读全文
posted @ 2007-05-09 11:12 阿米 阅读(222) | 评论 (0)  编辑
转几个实用的sql函数。      摘要: --将阿拉伯数字的钱转换成大写金额
CREATE function to_up(@num numeric(14,2))
returns varchar(100)
as
begin
declare @ndata varchar(20),@cdata varchar(100)
declare @nstr varchar(10),@zflag bit,@t varchar(10),@i int
set @ndata=RIGHT(SPACE(14)+CAST(CAST(ABS(@num*100) AS bigint) AS varchar(20)),14)
set @cdata=''
set @zflag=0;set @i=1

while @i<=14
begin
set @nstr=substring(@ndata,@i,1)
if @nstr<>'  阅读全文
posted @ 2007-02-25 11:37 阿米 阅读(644) | 评论 (2)  编辑
@@Identity      摘要: Many TSQL books show you how to use @@Identity to get the identity of the most recently added row. Many articles online, or in magazines show the same. What you might not know is that it is potentially a source for some very hard to trace bugs in your application.
@@Identity is potentially a very, very bad thing! In almost every case, you should use scope_identity() instead.

Why? @@Identity returns the most recently created identity for your current connection. When you first u  阅读全文
posted @ 2006-09-08 21:07 阿米 阅读(449) | 评论 (1)  编辑
Sql Server基本函数
posted @ 2006-07-20 11:59 阿米 阅读(67) | 评论 (0)  编辑