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

sql server back up database

sql server  »¹Ô­Ò»¸öÊý¾Ýµ½¾ßÌåµÄʱ¼ä
Êý¾Ý¿âµÄ¸½¼Ó:
sp_attach_db mark ,'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mark.mdf'
Êý¾Ý¿âµÄ·ÖÀë:
sp_deattach_db mark ,'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\mark.mdf'
Êý¾Ý¿âµÄÍêÈ«±¸·Ý:
backup database mark to disk='D:\Database\mark.bat'
Êý¾Ý¿âµÄ¼ÓÃܱ¸·Ý:
backup database mark to disk='D:\Database\mark.bat' with password 'password'
Êý¾Ý¿âµÄ²îÒ챸·Ý:
backup database mark to disk='D:\Database\mark.bat' with Diffreential
Êý¾Ý¿âÎļþ±¸·Ý:
backup database mark file='Filepath' to 'backupfile path'
Êý¾Ý¿âÎļþ×鱸·Ý
backup database mark filegroup='filegroup path' to 'back filegroup path '
Êý¾Ý¿âÈÕÖ¾±¸·Ý:
Êý¾Ý¿âµÄ»¹Ô­:
Êý¾Ý¿âµÄÍêÈ«»¹Ô­:
restore database mark  from disk='Database\mark.bat'
Êý¾Ý¿âµÄ²îÒ챸·Ý
alter database mark set recovery full
go
backup database mark to disk ='D:\Database\mark.bat'
go
restore database mark from disk='D:\Database\mark.bat' with recovery,replace,STOPAT='2010-04-19 16:10:40.100'
Êý¾Ý¿âÌí¼ÓÒ»¸ö±¸·ÝÉ豸
exec sp_addumpdevice 'disk','б¸·ÝÉ豸' ,'back up file path'


Ïà¹ØÎĵµ£º

ÔÚSQL Server 2005 ÖÐʹÓÃ.net³ÌÐò¼¯µÄÒ»Ïî×¢Òâ

ÔÚʹÓÃCLR´æ´¢¹ý³ÌÖÐÓöµ½µÄһЩÎÊÌ⣬ÔÚÕâÀï½øÐмǼ£º
´ò¿ªCLRµÄÖ§³Ö
--ÔÚSql ServerÖÐÖ´ÐÐÕâ¶Î´úÂë¿ÉÒÔ¿ªÆôCLR
exec sp_configure 'show advanced options', '1';
go
reconfigure;
go
exec sp_configure 'clr enabled', '1'
go
reconfigure;
exec sp_c ......

(ת)SQL Server¶àÌõ¼þ²éѯ¾­µäÀý×Ó

ÕâÊÇÒ»¸ö²»´íµÄÀý×Ó£¬ÌØתÔØ·ÖÏíÖ®¡£
 
------------±íÖеÄ×Ö¶Î---------------
CREATE TABLE [dbo].[stuInfo] (
[FNumber] [int] IDENTITY(1,1) NOT NULL ,
[FName] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[FNameen] [varchar] (35) COLLATE Chinese_PRC_CI_AS ,
[FSex] [char] (1) COLLATE C ......

ÔÚSQL SERVERµÄ±íÖУ¬ÈçºÎʵÏÖ²¿·Ö¼Ç¼µÄ¸´ÖÆ£¿

ÏÖÓÐSQL SERVERµÄÊý¾Ý±í£¨SalesItem£©,SalestemÓÐÒÔÏÂ×Ö¶Î:¿Í»§±àºÅ£¬ÏîÄ¿±àºÅ£¬¿Í»§Æ·ºÅ£¬»õ±Ò£¬µ¥¼Û£¬ÏúÊÛÔ±¡£ÐèÒª´Ó±íÖÐÈ¡³öC145µÄÊý¾Ý£¬ÔÙ°ÑÕâЩÊý¾ÝµÄ¿Í»§±àºÅ¸ÄΪC522£¬ÔÙ±£´æ»Ø±íSalesItemÎÊÌâ²¹³ä£ºÕâÀïÓÐ2²¿·ÖµÄÊý¾Ý£¬C145µÄÊý¾Ý²»±ä£¬»¹ÊÇÓеģ¬C522·ÝµÄÊý¾ÝÊÇ´Ó±íÖÐÈ¡³öC145¿Í»§±àºÅµÄÊý¾Ý£¬ÔÙ°ÑÕâЩÊý¾ÝµÄ¿Í»§± ......

SQLʹÓÃÁ´½Ó·þÎñÆ÷Ö´ÐÐÔ¶³ÌÊý¾Ý¿âÉϵĴ洢¹ý³Ì

 
--´´½¨Á´½Ó·þÎñÆ÷
exec sp_addlinkedserver 'server_tmp','','SQLOLEDB','Ô¶³Ì·þÎñÆ÷Ãû»òipµØÖ·'
exec sp_addlinkedsrvlogin 'server_tmp','false',null,'Óû§Ãû','ÃÜÂë'
exec sp_serveroption 'server_lnk','rpc out','true' --Õâ¸öÔÊÐíµ÷ÓÃÁ´½Ó·þÎñÆ÷ÉϵĴ洢¹ý³Ì
go
 
--µ÷Óãº
exec server_tmp.Êý¾ ......

Sql»ù±¾Óï¾äµÄѧϰ

--²éѯÿ¸öÈ˶©·¹µÄ´ÎÊý
select  username as ÐÕÃû, count(*) as ´ÎÊý from orderitems  group by UserName having count(*)=1
order by ÐÕÃû desc
select distinct username as δע²áÐÕÃû from orderitems
where username not in (select [Name] from Person)
select distinct username as ÒÑ×¢²áÐÕÃû fr ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ