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

Sql数据库重命名

1.查询出当前连接然后将其关闭
select spid
from master.dbo.sysprocesses
where dbid= db_id('数据库名')
 --db_id('DoNet')
如spid 值为 52.
2. 執行:   
 kill 52
3.修改數據庫名
EXEC sp_dboption 'old_db_name', 'Single User', 'false'
 EXEC sp_renamedb 'old_db_name', 'new_db_name'
EXEC sp_dboption 'new_db_name', 'Single User', 'FALSE'


相关文档:

sql点滴

子表查询,父表一定要加别名,否则数据会有问题,不报编译错
select * from table1 a where exist(select 1 from table2 where a.id=b.id)
存储过程结果集插入到现有表
insert into table1 exec procname args
联合已有表,紧跟在后面,对汇总很有用
select a from table1 union all select '合计'
结果集里的某 ......

oralce与SQL的函数使用区别

函数
SQLServer和Oracle的常用函数对比
  1.绝对值
  S:select abs(-1) value
  O:select abs(-1) value from dual
  2.取整(大)
  S:select ceiling(-1.001) value
  O:select ceil(-1.001) value from dual
  3.取整(小)
  S:select floor(-1.001) value
  O:select floor(-1.001 ......

SQL Having子句

SELECT
count
(
userName
)

from
`userInfo`

GROUP
BY
userName
HAVING
count
(
userName
)
>
1。
这个Having一定要放在GROUP BY的后面。
而且很特殊的情况是在有group by的时候,是不能用到where子句的。而且Having子句一般是放在其他子句的后面的。
当我们选不只一个栏位,且其 ......

按时间查询的SQL语句

1、按年查询:select * from dbo.td_BBSBoardInfo where (year(BBI_DateTime) between 2006 and 2009)
 按月、日查询只要将year 改为 month、data
2、按年月查询:select * from dbo.td_BBSBoardInfo where convert(varchar(6),BBI_DateTime,112) between 200606 and 200911 ......

[转]Oracle,sql server的空值(null)判断


sql server
替换null:isnull(arg,value)
如:select isnull(price,0.0) from orders                             ,如果price为null的话,用0 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号