久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

我可以在 Sql Server 中對(duì)一組數(shù)字執(zhí)行按位和嗎?

Can I perform a bitwise and on a set of numbers in Sql Server?(我可以在 Sql Server 中對(duì)一組數(shù)字執(zhí)行按位和嗎?)
本文介紹了我可以在 Sql Server 中對(duì)一組數(shù)字執(zhí)行按位和嗎?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個(gè)安全表,其中包含一個(gè)組和用戶列表,每個(gè)組和用戶都具有按位整數(shù)權(quán)限.對(duì)于每個(gè)給定的用戶,我想對(duì)他們的所有組和他們的個(gè)人權(quán)限記錄(如果存在)執(zhí)行按位 AND.

I have a security table containing a list of groups and users with a bitwise integer permission for each. For each given user, I would like to perform a bitwise AND on all of their groups and of their personal permission record, if present.

當(dāng)然,我可以在我的代碼中輕松地做到這一點(diǎn),但我更愿意在數(shù)據(jù)庫(kù)中做到這一點(diǎn),因?yàn)榭赡苡袛?shù)以千計(jì)的項(xiàng)目我正在查詢其權(quán)利.

Of course, I can easily do this in my code, but I'd rather do it in the database as there could be thousands of items I am querying the rights for.

相比游標(biāo),我更喜歡基于集合的解決方案.

I would prefer a set-based solution over a cursor.

請(qǐng)注意,我無(wú)法控制架構(gòu).

Note than I do not have control over the schema.

推薦答案

如果您想要按位或單位值的所有值,基于集合的解決方案是可能的:按位求和

A set-based solution is possible if all the values that you want to bitwise or are single-bit values: Performing a bitwise sum

或者,您可以使用不太優(yōu)雅的方法對(duì)非唯一值集進(jìn)行基于模糊集的按位運(yùn)算:

Alternatively, you can use a less-elegant method for vaguely-set-based bitwise operations on sets of non-unique values:

DECLARE @BitSum INT
SET @BitSum = 0
SELECT @BitSum = @BitSum | BitValue
FROM (
    SELECT 1 AS BitValue
    UNION SELECT 7
    UNION SELECT 16
) AS SampleValues
SELECT @BitSum

Hugo Kornelis 在另一篇文章中非常全面地回答了這個(gè)問題:http://www.eggheadcafe.com/software/aspnet/33139293/b??itwise-aggregate-function.aspx

Hugo Kornelis answers the question pretty comprehensively in this other post: http://www.eggheadcafe.com/software/aspnet/33139293/bitwise-aggregate-function.aspx

這篇關(guān)于我可以在 Sql Server 中對(duì)一組數(shù)字執(zhí)行按位和嗎?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個(gè)子標(biāo)記轉(zhuǎn)換為具有多個(gè)分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個(gè)表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計(jì)算值創(chuàng)建計(jì)算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對(duì)?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(hào)(問題和答案的組合))
主站蜘蛛池模板: 色婷婷婷婷色 | 亚洲精品久久久久久久久久久 | 久久精品国产免费高清 | 成人av电影在线 | 国产午夜在线 | 69av网 | 国外成人免费视频 | 亚洲高清av在线 | 久久精品国产亚洲 | 国产片淫级awww | 日日干日日操 | 黄频免费 | 国产一级片在线观看视频 | 欧美一级观看 | 国产成人精品午夜视频免费 | 一级一级毛片免费看 | 欧美一区免费 | 国产精品区二区三区日本 | 久久99成人 | 91精品国产一区二区三区 | 国产高清免费视频 | 琪琪午夜伦伦电影福利片 | 国产精品久久 | 精品中文字幕久久 | 国产一区二区毛片 | 国产成人精品免费视频 | 国产精品久久久久一区二区三区 | 久久久久久久久久久一区二区 | 欧美精品一区二区三区在线播放 | 欧美一级视频免费看 | 日本天堂一区二区 | 91在线网站 | 一级做a爰片久久毛片免费看 | 毛片一级网站 | 欧美日韩国产不卡 | 国产一二三区电影 | 日韩国产一区 | 久久成人一区 | 久久91精品国产一区二区 | 日韩中文字幕一区二区 | 国产亚洲一区二区精品 |