SQL Server下的可能有用的一些例句

2021-06-19 04:03:52 字數 738 閱讀 8885

sql隨機取一條記錄:select top 1 * from tablename order by newid()

newid()是掃瞄每一條資料時隨機生成的乙個值

sql查詢乙個表的所有欄位名

select a.name from syscolumns a inner join sysobjects b on a.id=b.id where b.name='tablename'

查詢乙個資料庫的所有表名

select name from sysobjects where xtype = 'u ' order by name

查詢所有表名或檢視名 

select table_name from information_schema.tables where table_type='base table' 

select * from information_schema.views 

select * from information_schema.tables where table_type='view'

獲取檢視的所有基表名 select

--object_name(id) as view_name,

object_name(depid) as table_name 

from sys.sysdepends 

where object_name(id) = 'zl_zv_nimimi' group by object_name(depid)

可能有用的函式

doublehypot double x,double y 求三角形斜邊 hypotenuse doublefrexp double x,int exp 將x分解成尾數和指數,指數存入exp,返回尾數 1.n的圈,迴圈數d步。p p d n 1 n 1 從1到n p p d n n 從0到n 1 b...

可能有用科技 系列目錄

收錄一下我這個爛人的擺爛記錄。最小直徑生成樹 oi wiki部分內容有誤,待勘誤,文末給出 鏈結,前面有些部分有點價值。子串行自動機 非常容易理解的啥也不是的自動機。多項式任意次冪 任意次根 大常數且沒用。字尾樹介紹很不全面,因為感覺這玩意比 sam 麻煩就徹底沒心思寫下去了。線性遞推與bm演算法 ...

今天可能有點衰

會同學 上午去廣州找乙個小學一直到高中的同學,昨天跟他約好的,他說今天到了給他 誰知道這個傢伙放我鴿子,我在賽馬場等了他1個小時,手機一直關機,從我這裡到那裡坐公汽得差不多兩個小時呢,幸好這兩天天氣轉涼,不然我可饒不了他。下午兩點過他才發簡訊說剛起床,真是個混蛋。本來打算是先會了他再去白雲區見另乙個...