色16p_色综合色狠狠天天久久婷婷基地_国产成人精品视频2021_98精品国产高清在线看入口 - 亚洲精品国产字幕久久不卡

 

服務(wù)器系統(tǒng)集成及數(shù)據(jù)服務(wù)中心

 

一級欄目
一級欄目
一級欄目
一級欄目
一級欄目
一級欄目
一級欄目
一級欄目
鎶琛?sh霉)璩囨枡…………………………………………………………………………………………>>>

處理SQL-server數(shù)據(jù)庫附加失敗

快速刪除數(shù)據(jù)庫中所有表中的數(shù)據(jù)

select ''''truncate table '''' + Name + '''''''' from sysobjects where xtype=''''U'''' order by name asc

該條語句執(zhí)行之后會將數(shù)據(jù)庫中所有的表都查詢出來,復(fù)制出來之后執(zhí)行truncate語句即可

*******************

alter database zygl3_data set emergency

一、附加SQL2005數(shù)據(jù)庫失敗解決方法

參考恢復(fù)方法:

1、停止數(shù)據(jù)庫服務(wù)。

2、將需要恢復(fù)的數(shù)據(jù)庫文件復(fù)制到另外的位置。

3、啟動數(shù)據(jù)庫服務(wù)。

4、確認要恢復(fù)的數(shù)據(jù)庫文件已經(jīng)成功復(fù)制到另外的位置,然后在SQL Server Management Studio中刪除要恢復(fù)的數(shù)據(jù)庫。

5、新建同名的數(shù)據(jù)庫(數(shù)據(jù)庫文件名也要相同)。

6、停止數(shù)據(jù)庫服務(wù)。

7、用第2步中備份的.mdf文件覆蓋新數(shù)據(jù)庫的同名文件。

8、啟動數(shù)據(jù)庫服務(wù)。

9、運行alter database dbname set emergency,將數(shù)據(jù)庫設(shè)置為emergency mode

10、運行下面的命令就可以恢復(fù)數(shù)據(jù)庫:

use master
declare @databasename varchar(255)
set @databasename=''''你的數(shù)據(jù)庫名''''
exec sp_dboption @databasename, N''''single'''', N''''true''''將目標數(shù)據(jù)庫置為單用戶狀態(tài)
dbcc checkdb(@databasename,REPAIR_ALLOW_DATA_LOSS)
dbcc checkdb(@databasename,REPAIR_REBUILD)
exec sp_dboption @databasename, N''''single'''', N''''false''''將目標數(shù)據(jù)庫置為多用戶狀態(tài)


如果你一切都順得的話就如上的步驟就可以成功了,下面我們將對特殊的狀態(tài)進行分析

1、一個或多個文件與數(shù)據(jù)庫的主文件不匹配。如果是嘗試附加數(shù)據(jù)庫,請使用正確的文件重試該操作。如果這是現(xiàn)有數(shù)據(jù)庫,則文件可能已損壞,應(yīng)該從備份進行還原。
日志文件 ''''E:/Program Files/Microsoft SQL Server 2005/MSSQL.1/MSSQL/DATA/dnt2_db_log.ldf'''' 與主文件不匹配。該文件可能來自另一數(shù)據(jù)庫,或者可能以前重新生成了日志。
消息 5123,級別 16,狀態(tài) 1,第 5 行
嘗試打開或創(chuàng)建物理文件 ''''F:/項目/愛社區(qū)/數(shù)據(jù)庫/dnt2_db_log.ldf'''' 時,CREATE FILE 遇到操作系統(tǒng)錯誤 3(系統(tǒng)找不到指定的路徑。)。
消息 5024,級別 16,狀態(tài) 2,第 5 行
在 sysfiles1 中找不到主日志文件所對應(yīng)的條目。無法重建日志。
消息 5028,級別 16,狀態(tài) 2,第 5 行
系統(tǒng)無法激活足夠的數(shù)據(jù)庫來重建日志。

解決方案:手動創(chuàng)建E:/Program Files/Microsoft SQL Server 2005/MSSQL.1/MSSQL/DATA目錄就可以了,然后再執(zhí)行

上述第10步步驟,就會在E:/Program Files/Microsoft SQL Server 2005/MSSQL.1/MSSQL/DATA產(chǎn)生一個日志文件。數(shù)據(jù)庫就可以正常使用了


2、另外值得說說的就是,如果該數(shù)據(jù)在備份時發(fā)生
System.Data.SqlClient.SqlError: 在處理 ''''BackupMetadata'''' 元數(shù)據(jù)(數(shù)據(jù)庫 ID 6,文件 ID 65537)時出錯。 (Microsoft.SqlServer.Smo),說明在附加過程中沒有產(chǎn)生全文索引文件

解決方法:
右鍵數(shù)據(jù)庫->屬性->文件->選擇使用全文索引
如果執(zhí)行正常那么就可以直接進行備份操作了。

二、一些不錯的sql語句

1、說明:復(fù)制表(只復(fù)制結(jié)構(gòu),源表名:a 新表名:b) (Access可用)
法一:select  into b from a where 11
法二:select top 0  into b from a
也可以SELECT * INTO  新標  FROM 原始表  where 1=2

2、說明:拷貝表(拷貝數(shù)據(jù),源表名:a 目標表名:b) (Access可用)
insert into b(a, b, c) select d,e,f from b

3、說明:跨數(shù)據(jù)庫之間表的拷貝(具體數(shù)據(jù)使用絕對路徑) (Access可用)
insert into b(a, b, c) select d,e,f from b in ‘具體數(shù)據(jù)庫’    where 條件
例子:..from b in ''''&Server.MapPath(.)&data.mdb &'''' where..

4、說明:子查詢(表名1:a 表名2:b)
select a,b,c from a where a IN (select d from b )    或者    select a,b,c from a where a IN (1,2,3)

5、說明:顯示文章、提交人和最后回復(fù)時間
select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where

table.title=a.title) b

6、說明:外連接查詢(表名1:a 表名2:b)
select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c

7、說明:在線視圖查詢(表名1:a )
select  from (SELECT a,b,c FROM a) T where t.a  1

8、說明:between的用法,between限制查詢數(shù)據(jù)范圍時包括了邊界值,not between不包括
select  from table1 where time between time1 and time2
select a,b,c, from table1 where a not between 數(shù)值1 and 數(shù)值2

9、說明:in 的使用方法
select  from table1 where a [not] in (‘值1’,’值2’,’值4’,’值6’)

10、說明:兩張關(guān)聯(lián)表,刪除主表中已經(jīng)在副表中沒有的信息
delete from table1 where not exists ( select  from table2 where table1.field1=table2.field1 )

11、說明:四表聯(lián)查問題:
select  from a left inner join b on a.a=b.b right inner join c on a.a=c.c inner join d on a.a=d.d where

.....

12、說明:日程安排提前五分鐘提醒
SQL select  from 日程安排 where datediff(''''minute'''',f開始時間,getdate())5

13、說明:一條sql 語句搞定數(shù)據(jù)庫分頁
select top 10 b. from (select top 20 主鍵字段,排序字段 from 表名 order by 排序字段 desc) a,表名 b where

b.主鍵字段 = a.主鍵字段 order by a.排序字段

14、說明:前10條記錄
select top 10  form table1 where 范圍

15、說明:選擇在每一組b值相同的數(shù)據(jù)中對應(yīng)的a最大的記錄的所有信息(類似這樣的用法可以用于論壇每月排行榜,

每月熱銷產(chǎn)品分析,按科目成績排名,等等.)
select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)

16、說明:包括所有在 TableA 中但不在 TableB和TableC 中的行并消除所有重復(fù)行而派生出一個結(jié)果表
(select a from tableA ) except (select a from tableB) except (select a from tableC)

17、說明:隨機取出10條數(shù)據(jù)
select top 10  from tablename order by newid()

18、說明:隨機選擇記錄
select newid()

19、說明:刪除重復(fù)記錄
Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)

20、說明:列出數(shù)據(jù)庫里所有的表名
select name from sysobjects where type=''''U''''

21、說明:列出表里的所有的
select name from syscolumns where id=object_id(''''TableName'''')

22、說明:列示type、vender、pcs字段,以type字段排列,case可以方便地實現(xiàn)多重選擇,類似select 中的case。
select type,sum(case vender when ''''A'''' then pcs else 0 end),sum(case vender when ''''C'''' then pcs else 0

end),sum(case vender when ''''B'''' then pcs else 0 end) FROM tablename group by type
顯示結(jié)果:
type    vender     pcs
電腦     A          1
電腦     A          1
光盤     B          2
光盤     A          2
手機     B          3
手機     C          3

23、說明:初始化表table1
TRUNCATE TABLE table1

24、說明:選擇從10到15的記錄
select top 5  from (select top 15  from table order by id asc) table_別名 order by id desc

25,查看當(dāng)前操作的數(shù)據(jù)庫
  select db_name(dbid) from master.dbo.sysprocess where spid=@@spid
Trackback httptb.blog.csdn.NETTrackBack.aspxPostId=379405

發(fā)布時間:2017/6/11 閱讀:10023次 來源:煙臺數(shù)據(jù)恢復(fù)老李
 


 
鎶琛?sh霉)璩囨枡分類
   
  行業(yè)新聞
 
  公司動態(tài)
 
  技術(shù)資料
 
  電腦維修
 
  恢復(fù)案例
 
  SQL數(shù)據(jù)庫
 
  磁盤陣列
 
  服務(wù)器
 
  財務(wù)軟件
 
  網(wǎng)絡(luò)問題
 
  linux-XFS
 
  辦公文件
 
  操作系統(tǒng)
 
  日常生活(煙臺)
 
  網(wǎng)站相關(guān)
 
   
 
友情鏈接
 
 
 
 
 
   
公司地址:煙臺電腦市場A310
電話:15336380195 E-Mail:sd_lzc@sina.com
Copyright©2011-2012 煙臺知昭電子 All Rights Reserved.
魯ICP備11014811號-1
您是本站第 位訪問者