Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL Server 2005 ²éѯ·ÖÎöÖÐɾ³ýÊý¾Ý¿â

USE   master  
GO
DECLARE   @dbname   sysname  
SET  @dbname='TEST' --Õâ¸öÊÇҪɾ³ýµÄÊý¾Ý¿â¿âÃû  
DECLARE @s  NVARCHAR(1000)  
DECLARE tb CURSOR local FOR  
SELECT s='KILL '+CAST(spid AS NVARCHAR)  
from master..sysprocesses    
WHERE dbid=DB_ID(@dbname)  
OPEN tb
FETCH next from tb INTO @s  
WHILE @@FETCH_STATUS=0  
BEGIN  
 EXEC(@s)  
 FETCH next from tb INTO @s  
END
CLOSE tb
DEALLOCATE tb
  
EXEC('DROP DATABASE ['+@dbname+']')  


Ïà¹ØÎĵµ£º

¾­µäSQLÓï¾ä

 Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack ......

sql 2005 rownumÓ÷¨ÒÔ¼°´øorder by ×Ó²éѯµÄÓ÷¨

--   sql   2005
  1.rownumÓ÷¨
  select   *   from(  
          Select   rownum=row_number()   over(order   by   1),*   from   table
  )a   where   rownum   between  ......

ÔÚ´ò°ü³ÌÐòÖÐ×Ô¶¯°²×°SQL ServerÊý¾Ý¿â

1¡¢´´½¨°²×°ÏîÄ¿“Setup1”°²×°ÏîÄ¿
ÔÚ“Îļþ”²Ëµ¥ÉÏÖ¸Ïò“Ìí¼ÓÏîÄ¿”£¬È»ºóÑ¡Ôñ“н¨ÏîÄ¿”¡£
ÔÚ“Ìí¼ÓÐÂÏîÄ¿”¶Ô»°¿òÖУ¬Ñ¡Ôñ“ÏîÄ¿ÀàÐÍ”´°¸ñÖеē°²×°ºÍ²¿ÊðÏîÄ¿”£¬È»ºóÑ¡Ôñ“Ä£°å”´°¸ñÖеē°²×°ÏîÄ¿”¡£ÔÚ&ldquo ......

Sql Server²éѯÊý¾Ý¼¯ÐÐÁл¥»»

Ðл»ÁУº
--> Éú³É²âÊÔÊý¾Ý±í: [tb]
IF OBJECT_ID('[tb]') IS NOT NULL
    DROP TABLE [tb]
GO
CREATE TABLE [tb] ([a] [int],[b] [int],[c] [int])
INSERT INTO [tb]
SELECT '3','9','5' UNION ALL
SELECT '5','2','7' UNION ALL
SELECT '6','3','8'
--SELECT * from [tb]
-->SQL²éѯÈçÏ ......

sql³£ÓÃ

select [name] from sysdatabases order by name--µÃµ½Êý¾Ý¿âÖÐËùÓеĿâÃû
select [name] from sysobjects where xtype='U'and [name]<>'dtproperties' order by [name]--µÃµ½Êý¾Ý¿â±íÖеÄÁбí
select [name] from sysobjects where xtype='V' and [name]<>'syssegments' and [name]<>'sysconstraints' ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ