av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

如何查詢SQLServer數(shù)據(jù)庫沒有主鍵的表并增加主鍵

SQL Server數(shù)據(jù)庫中,如果一個表沒有主鍵,我們該如何查詢呢?本文我們主要就介紹了如何查詢數(shù)據(jù)庫中沒有主鍵的表名并為其增加主鍵的方法,希望能夠?qū)δ兴鶐椭?/p>

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:域名與空間、虛擬主機(jī)、營銷軟件、網(wǎng)站建設(shè)、薩嘎網(wǎng)站維護(hù)、網(wǎng)站推廣。

該功能的實(shí)現(xiàn)代碼如下:

 
 
 
  1. declare @tablename sysname 
  2. declare @strsql nchar(500) 
  3. declare tableNameCursor cursor for
  4. select b.name from sysobjects b where xtype='U' and  b.name not in 
  5. (select object_name(a.parent_obj)  from sysobjects a where xtype='PK' ) 
  6. open tableNameCursor   
  7. fetch next from tableNameCursor into @tablename 
  8. while @@FETCH_STATUS = 0 
  9. begin
  10. print @tablename 
  11. set @strsql= 'alter table ' + @tablename + ' add primary key (id) '
  12. print @strsql 
  13. exec (@strsql) 
  14. fetch next from tableNameCursor into @tablename 
  15. end
  16. close tableNameCursor 
  17. deallocate  tableNameCursor

以上就是SQL Server數(shù)據(jù)庫中查詢沒有主鍵的表的名稱并為其增加主鍵的實(shí)現(xiàn)代碼,希望本次的代碼示例能夠給您帶來一些收獲,謝謝!


新聞標(biāo)題:如何查詢SQLServer數(shù)據(jù)庫沒有主鍵的表并增加主鍵
鏈接URL:http://uogjgqi.cn/article/dhiochs.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流