如何獲取SqlServer2005數(shù)據(jù)庫表結(jié)構(gòu)_Mssql數(shù)據(jù)庫教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:如何在SQL Server2005中還原數(shù)據(jù)庫對于在SQL Server2000中的還原數(shù)據(jù)庫,很多朋友都是使用過的,一起來也很簡單,選擇文件后,選擇強制還原,問題即可解決,然而在2005中卻不行了,原因是:2005中數(shù)據(jù)庫的備份中記錄了備份數(shù)據(jù)庫的地址,在你還原的過程中,你必須將此地址換成你電腦上要還原
1.獲取表的基本字段屬性

2.如果還想要獲取字段的描述信息則

3.單獨查詢表的遞增字段

4.獲取表的主外鍵
--獲取SqlServer中表結(jié)構(gòu)
SELECT syscolumns.name,systypes.name,syscolumns.isnullable,
syscolumns.length
FROM syscolumns, systypes
WHERE syscolumns.xusertype = systypes.xusertype
AND syscolumns.id = object_id('你的表名')
運行效果SELECT syscolumns.name,systypes.name,syscolumns.isnullable,
syscolumns.length
FROM syscolumns, systypes
WHERE syscolumns.xusertype = systypes.xusertype
AND syscolumns.id = object_id('你的表名')

2.如果還想要獲取字段的描述信息則
--獲取SqlServer中表結(jié)構(gòu) 主鍵,及描述
declare @table_name as varchar(max)
set @table_name = '你的表名'
select sys.columns.name, sys.types.name, sys.columns.max_length, sys.columns.is_nullable,
(select count(*) from sys.identity_columns where sys.identity_columns.object_id = sys.columns.object_id and sys.columns.column_id = sys.identity_columns.column_id) as is_identity ,
(select value from sys.extended_properties where sys.extended_properties.major_id = sys.columns.object_id and sys.extended_properties.minor_id = sys.columns.column_id) as description
from sys.columns, sys.tables, sys.types where sys.columns.object_id = sys.tables.object_id and sys.columns.system_type_id=sys.types.system_type_id and sys.tables.name=@table_name order by sys.columns.column_id
運行效果declare @table_name as varchar(max)
set @table_name = '你的表名'
select sys.columns.name, sys.types.name, sys.columns.max_length, sys.columns.is_nullable,
(select count(*) from sys.identity_columns where sys.identity_columns.object_id = sys.columns.object_id and sys.columns.column_id = sys.identity_columns.column_id) as is_identity ,
(select value from sys.extended_properties where sys.extended_properties.major_id = sys.columns.object_id and sys.extended_properties.minor_id = sys.columns.column_id) as description
from sys.columns, sys.tables, sys.types where sys.columns.object_id = sys.tables.object_id and sys.columns.system_type_id=sys.types.system_type_id and sys.tables.name=@table_name order by sys.columns.column_id

3.單獨查詢表的遞增字段
--單獨查詢表遞增字段
select [name] from syscolumns where
id=object_id(N'你的表名') and COLUMNPROPERTY(id,name,'IsIdentity')=1
運行效果select [name] from syscolumns where
id=object_id(N'你的表名') and COLUMNPROPERTY(id,name,'IsIdentity')=1

4.獲取表的主外鍵
--獲取表主外鍵約束
exec sp_helpconstraint '你的表名' ;
exec sp_helpconstraint '你的表名' ;
運行效果
分享:SQL Server2000安裝時出現(xiàn)錯誤及解決安裝SQL Server 遇到錯誤提示: 以前的某個程序安裝已在安裝計算機上創(chuàng)建掛起的文件操作。運行安裝程序之前必須重新啟動計算機!。 打開注冊表編輯器,在HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession Manager 中找到 PendingFileRenameOperations
相關(guān)Mssql數(shù)據(jù)庫教程:
- sql 語句練習(xí)與答案
- 深入C++ string.find()函數(shù)的用法總結(jié)
- SQL Server中刪除重復(fù)數(shù)據(jù)的幾個方法
- sql刪除重復(fù)數(shù)據(jù)的詳細(xì)方法
- SQL SERVER 2000安裝教程圖文詳解
- 使用sql server management studio 2008 無法查看數(shù)據(jù)庫,提示 無法為該請求檢索數(shù)據(jù) 錯誤916解決方法
- SQLServer日志清空語句(sql2000,sql2005,sql2008)
- Sql Server 2008完全卸載方法(其他版本類似)
- sql server 2008 不允許保存更改,您所做的更改要求刪除并重新創(chuàng)建以下表
- SQL Server 2008 清空刪除日志文件(瞬間日志變幾M)
- Win7系統(tǒng)安裝MySQL5.5.21圖解教程
- 將DataTable作為存儲過程參數(shù)的用法實例詳解
Mssql數(shù)據(jù)庫教程Rss訂閱編程教程搜索
Mssql數(shù)據(jù)庫教程推薦
- Sql server 2008 express遠(yuǎn)程登錄實例設(shè)置 圖文教程
- 解析 SQL Server 2008 的精妙之處
- 詳解:SQL Server 2000 的各種版本
- 解讀數(shù)據(jù)庫的一些常識
- 兩種技巧處理SQL Server中的單引號
- 教你快速掌握數(shù)據(jù)庫設(shè)計范式的基本概念
- Sql Server 2008完全卸載方法(其他版本類似)
- sql里將重復(fù)行數(shù)據(jù)合并為一行數(shù)據(jù)使用逗號進(jìn)行分隔
- 淺談Linq To Sql集成數(shù)據(jù)庫語言的優(yōu)劣
- 如何解決MySQL 5數(shù)據(jù)庫連接超時問題
- 相關(guān)鏈接:
- 教程說明:
Mssql數(shù)據(jù)庫教程-如何獲取SqlServer2005數(shù)據(jù)庫表結(jié)構(gòu)
。