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Óï¾ä£¬³ý·ÇÄãÊÇÈ«²¿Óÿؼþ°ó¶¨µÄ·½Ê½£¬µ«²ÉÓÿؼþ°ó¶¨µÄ·½Ê½´æÔÚ×ÅÁé»îÐԲЧÂʵ͡¢¹¦ÄÜÈõµÈµÈȱµã¡£Òò´Ë£¬´ó¶àÊýµÄ³ÌÐòÔ±¼«ÉÙ»ò½ÏÉÙÓÃÕâÖְ󶨵ķ½Ê½¡£¶ø²ÉÓ÷ǰ󶨷½Ê½Ê±Ðí¶à³ÌÐòÔ±´ó¶¼ºöÂÔÁ˶Ե¥ÒýºÅµÄÌØÊâ´¦Àí£¬Ò»µ©SQLÓï¾äµÄ²éѯÌõ¼þµÄ±äÁ¿Óе¥ÒýºÅ³öÏÖ£¬Êý¾Ý¿âÒýÇæ¾Í»á±¨´íÖ¸³öSQLÓ ......
package cn.com.hbivt.util;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class StringUtils {
//¹ýÂËͨ¹ýÒ³Ãæ±íµ¥Ìá½» ......
ÔÚsql server2005ÖÐÔõô½øÐжàÖµÓë¶àÖµÖ®¼äµÄ±È½Ï£¿¿ÉÒԱȽÏÂð£¿
ÀýÈ磺
ÎÒÒªÖ¤Ã÷1£¬2£¬3£¬4£¬5£¨ÔÚ±íÖвéѯ³öµÄÖµ£©Óë3£¬2£¬6£¬5£¨×Ô¶¨Òå²ÎÊý£©Á½ÌõÊý¾ÝÖÐÓÐÏàͬµÄÖµ£¬²¢½«ÏàֵͬµÄÁеÄÏàÓ¦±íÐÅÏ¢ÓÃprint´òÓ¡³öÀ´
×¢Ò⣬²»Äܵ¥¸ö±È½Ï……
²»ÖªµÀ¿É²»¿É²éѯ³öÀ´£¬ Çë¸÷λ¸ßÊÖ°ï°ïæ……
......
×Ó±í²éѯ£¬¸¸±íÒ»¶¨Òª¼Ó±ðÃû£¬·ñÔòÊý¾Ý»áÓÐÎÊÌ⣬²»±¨±àÒë´í
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 'ºÏ¼Æ'
½á¹û¼¯ÀïµÄij ......
ÊÓͼ¿ÉÒÔ±»¿´³ÉÊÇÐéÄâ±í»ò´æ´¢²éѯ¡£¿Éͨ¹ýÊÓͼ·ÃÎʵÄÊý¾Ý²»×÷Ϊ¶ÀÌصĶÔÏó´æ´¢ÔÚÊý¾Ý¿âÄÚ¡£Êý¾Ý¿âÄÚ´æ´¢µÄÊÇ SELECT Óï¾ä¡£SELECT Óï¾äµÄ½á¹û¼¯¹¹³ÉÊÓͼËù·µ»ØµÄÐéÄâ±í¡£Óû§¿ÉÒÔÓÃÒýÓñíʱËùʹÓõķ½·¨£¬ÔÚ Transact-SQL Óï¾äÖÐͨ¹ýÒýÓÃÊÓͼÃû³ÆÀ´Ê¹ÓÃÐéÄâ±í¡£Ê¹ÓÃÊÓͼ¿ÉÒÔʵÏÖÏÂÁÐÈÎÒ»»òËùÓй¦ÄÜ£º
¡¡¡¡½«Óû§ÏÞ¶¨ÔÚ±í ......