易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL Server 2000 重命名数据库

某项目之前的数据库有变化,但是以前写的程序是支持老数据库的,新数据库有一些问题,需要修改,但是数据库就重复了,于是就要把开发机上之前的数据库重新命名。
这里记录一下步骤(旧名称:MobileMsg,新名称:MobileMsg_old):
1、关掉企业管理器,打开查询分析器;
2、修改数据库名称:
EXEC sp_dboption 'MobileMsg', 'Single User', 'TRUE'
Go
EXEC sp_renamedb 'MobileMsg', 'MobileMsg_old'
Go
EXEC sp_dboption 'MobileMsg_old', 'Single User', 'FALSE'
Go
3、修改修改数据库的逻辑名称:
alter database MobileMsg_old modify file(name='MobileMsg_Data', newname='MobileMsg_old_Data')
alter database MobileMsg_old modify file(name='MobileMsg_Log',  newname='MobileMsg_old_Log')
Go
4、关闭SQL Server服务,修改物理名称:
C:\Program Files\Microsoft SQL Server\MSSQL\Data\MobileMsg_old_Data.MDF
C:\Program Files\Microsoft SQL Server\MSSQL\Data\MobileMsg_old_Log.MDF
5、重命名数据库物理文件:
exec xp_cmdshell 'rename  C:\Program Files\Microsoft SQL Server\MSSQL\Data\MobileMsg_Data.MDF C:\Program Files\Microsoft SQL Server\MSSQL\Data\MobileMsg_old_Data.MDF'
exec xp_cmdshell 'rename  C:\Program Files\Microsoft SQL Server\MSSQL\Data\MobileMsg_Log.LDF  C:\Program Files\Microsoft SQL Server\MSSQL\Data\MobileMsg_old_Log.LDF'
go


相关文档:

一次插入多条信息(sql)

注释:只适合单表单列数据,
create database test
go
use test
go
create table users
(
:id int identity(1,1) primary key not null,
:name nvarchar(20)
)
go
create proc sp_Inserts
@Names nvarchar(4000)
as
declare @Name nvarchar(20),@ErrorSum int
:set @ErrorSum = 0
:begin tra ......

Shrink SQL Server 2008 Database + Log File Script

Use DatabaseName
--DB shrink
--获取database 空余空间, 决定是否作shrinkDB
exec [DBNAME].dbo.sp_spaceused
DBCC ShrinkDB(DBNAME)
--Log file shrink
Use DatabaseName
GO
Alter Database DatabaseName Set Recovery Simple
GO
Alter Database DatabaseName Set Recovery Full
GO
DBCC SHRINKFILE ('Log ......

SQL Server索引统计信息未及时更新,导致排序混乱

今天,遇到了这样的一个例子:
SQL Server索引统计信息未及时更新,导致排序混乱
我们知道,在sql
server上创建索引后,同时会对该索引上的值进行排序,但对于新增加的值,如果未能及时更新统计信息,将有可能导致排序的混乱,也就是没有排序。
这是产生问题的语句:
Select * from V_L_IcStockProInEntry Where FInt ......

用sql操作oracle的blob字段

用sql操作oracle的blob字段
1、查询
select utl_raw.cast_to_varchar2(dlob),id from system.t_htinfo 
2、插入
insert into system.t_htinfo  values ('3',utl_raw.cast_to_raw('你'));
3、更新
update system.t_htinfo set fld_value=utl_raw.cast_to_raw('1') where fh_nm=1820648 and form_index=52
......

同一表多字段同时重复记录的SQL查询及处理数

同一表多字段同时重复记录的SQL查询及处理数
比如现在有一人员表 (表名:peosons)
若想将姓名、身份证号、住址这三个字段完全相同的记录查询出来
select p1.* from persons p1,persons p2 where p1.idp2.id and p1.cardid = p2.cardid and p1.pname = p2.pname and p1.address ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号