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'
Ïà¹ØÎĵµ£º
ÔÚʹÓÃ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 ......
ÕâÊÇÒ»¸ö²»´íµÄÀý×Ó£¬ÌØתÔØ·ÖÏíÖ®¡£
------------±íÖеÄ×Ö¶Î---------------
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µÄÊý¾Ý±í£¨SalesItem£©,SalestemÓÐÒÔÏÂ×Ö¶Î:¿Í»§±àºÅ£¬ÏîÄ¿±àºÅ£¬¿Í»§Æ·ºÅ£¬»õ±Ò£¬µ¥¼Û£¬ÏúÊÛÔ±¡£ÐèÒª´Ó±íÖÐÈ¡³öC145µÄÊý¾Ý£¬ÔÙ°ÑÕâЩÊý¾ÝµÄ¿Í»§±àºÅ¸ÄΪC522£¬ÔÙ±£´æ»Ø±íSalesItemÎÊÌâ²¹³ä£ºÕâÀïÓÐ2²¿·ÖµÄÊý¾Ý£¬C145µÄÊý¾Ý²»±ä£¬»¹ÊÇÓеģ¬C522·ÝµÄÊý¾ÝÊÇ´Ó±íÖÐÈ¡³öC145¿Í»§±àºÅµÄÊý¾Ý£¬ÔÙ°ÑÕâЩÊý¾ÝµÄ¿Í»§± ......
--´´½¨Á´½Ó·þÎñÆ÷
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.Êý¾ ......
--²éѯÿ¸öÈ˶©·¹µÄ´ÎÊý
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 ......