{"id":340227,"date":"2022-10-25T15:00:54","date_gmt":"2022-10-25T15:00:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=340227"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=340227","title":{"rendered":"<span>\u041d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u0432 SQL Server 2022<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>21 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f 2022 \u0433.\u00a0<a href=\"https:\/\/sqlperformance.com\/author\/itzikbengan\" rel=\"noopener noreferrer nofollow\">Itzik Ben-Gan<\/a> <\/p>\n<p>\u0412 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f T-SQL \u043d\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u0430 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0431\u0438\u0442\u043e\u0432\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e.\u00a0\u041c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0431\u043e\u0440 \u0444\u043b\u0430\u0433\u043e\u0432 (\u0434\u0430\/\u043d\u0435\u0442, \u0432\u043a\u043b\/\u0432\u044b\u043a\u043b, \u0438\u0441\u0442\u0438\u043d\u0430\/\u043b\u043e\u0436\u044c) \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0439 \u0438\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0435, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043b\u0430\u0433.\u00a0\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\/\u0440\u043e\u043b\u0438.\u00a0\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435.\u00a0\u0414\u0430\u0436\u0435 SQL Server \u0445\u0440\u0430\u043d\u0438\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0444\u043b\u0430\u0433\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435.\u00a0\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043f\u043b\u0430\u043d\u0430 set_options \u0438 required_cursor_options, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f      \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-exec-plan-attributes-transact-sql\" rel=\"noopener noreferrer nofollow\">sys.dm_exec_plan_attributes.<\/a><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0435\u0430\u043d\u0441\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/options-transact-sql\" rel=\"noopener noreferrer nofollow\">@@OPTIONS<\/a><\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u00ab<a href=\"https:\/\/learn.microsoft.com\/ru-ru\/sql\/database-engine\/configure-windows\/configure-the-user-options-server-configuration-option?view=sql-server-ver16\" rel=\"noopener noreferrer nofollow\">user options<\/a>\u00bb\u00a0\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/columns-updated-transact-sql\" rel=\"noopener noreferrer nofollow\">COLUMNS_UPDATED<\/a>\u00a0, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0431\u044b\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/grouping-id-transact-sql\" rel=\"noopener noreferrer nofollow\">GROUPING_ID<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043e\u043a.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0442\u043e\u0433\u043e, \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u043b\u0430\u0433, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438\u043b\u0438 \u0441\u043d\u044f\u0442\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u043b\u0430\u0433\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u0444\u043b\u0430\u0433\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b, \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432, \u0441\u0434\u0432\u0438\u0433 \u0431\u0438\u0442\u043e\u0432 \u0432\u043b\u0435\u0432\u043e \u0438\u043b\u0438 \u0432\u043f\u0440\u0430\u0432\u043e \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>\u0414\u043e SQL Server 2022 \u0432 T-SQL \u0431\u044b\u043b\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0442\u0430\u043c\u0438.\u00a0\u0418\u043c\u0435\u043b\u0430\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-and-transact-sql\" rel=\"noopener noreferrer nofollow\">&amp; (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0418 \/ <u>bitwise AND)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-or-transact-sql\" rel=\"noopener noreferrer nofollow\">| (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0418\u041b\u0418 \/ <u>bitwise OR)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-exclusive-or-transact-sql\" rel=\"noopener noreferrer nofollow\">^ (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0435 \u0418\u041b\u0418 \/ <u>bitwise XOR)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-not-transact-sql\" rel=\"noopener noreferrer nofollow\">~ (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u041d\u0415 \/ <u>bitwise NOT)<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0431\u0438\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0443\u0442\u0451\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.\u00a0\u041d\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0438 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u044e \u043b\u043e\u0433\u0438\u043a\u0435.<\/p>\n<p>SQL Server 2022 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0438\u0442\u0430\u043c\u0438, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u0445 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c\u0438.\u00a0\u041d\u0438\u0436\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b:\u00a0<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/get-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f GET_BIT<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/get-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">GET_BIT function<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/set-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f SET_BIT<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/set-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">SET_BIT function<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/bit-count-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f BIT_COUNT<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/bit-count-transact-sql\" rel=\"noopener noreferrer nofollow\">BIT_COUNT function<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/left-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f LEFT_SHIFT \/ \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &lt;&lt;<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/left-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">LEFT_SHIFT function \/ &lt;&lt; operator<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/right-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f RIGHT_SHIFT \/ \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 >><\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/right-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">RIGHT_SHIFT function \/ >> operator<\/a>)<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u0438\u0445 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.\u00a0\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.\u00a0\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u0440\u0435\u0448\u0438\u0442\u044c.<\/p>\n<h2>GET_BIT \u0438 SET_BIT<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f GET_BIT \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0431\u0438\u0442 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0431\u0438\u0442\u043e\u0432\u044b\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>GET_BIT (\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435)<\/code><\/pre>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c (integer) \u0438\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c (binary, \u043d\u0435 LOB).\u00a0\u0411\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 0 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0431\u0438\u0442 \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0430\u043b\u0435\u0432\u043e.\u00a0\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0435 0 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e (\u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u043e\u0433\u043e) \u0431\u0438\u0442\u0430, 1 \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u2026, 31 \u0434\u043b\u044f \u0442\u0440\u0438\u0434\u0446\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.\u00a0\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f BIT.\u00a0\u042d\u0442\u043e 1, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u0438 0, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0435\u0430\u043d\u0441\u0430 ARITHABORT \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u0431\u0438\u0442 \u043f\u043e \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0435 \u0440\u0430\u0432\u043d\u044b\u043c 6, \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 @@options.\u00a0\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0438\u0436\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u044d\u0442\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u0435\u0430\u043d\u0441\u0435:<\/p>\n<pre><code class=\"sql\">SELECT GET_BIT( @@OPTIONS, 6 );<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 ARITHABORT \u0432 \u0441\u0435\u0430\u043d\u0441\u0435 \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<pre><code>----- 1<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f SET_BIT \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u0431\u0438\u0442 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 1 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043b\u0438 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (1 \u0438\u043b\u0438 0), \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043e.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>SET_BIT (\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 [, \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435])<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 GET_BIT.\u00a0\u0412\u0432\u043e\u0434 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 (\u043d\u043e \u043e\u043d \u0442\u043e\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c 1 \u0438\u043b\u0438 0).<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0430\u043a \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 @@OPTIONS, \u0442\u0430\u043a \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c ARITHABORT:<\/p>\n<pre><code class=\"sql\">SELECT @@OPTIONS AS cursession, SET_BIT( @@OPTIONS, 6, 0 ) AS cursession_ARITHABORT_off;<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">cursession  cursession_ARITHABORT_off ----------- ------------------------- 5496 \u00a0\u00a0\u00a0\u00a0\u00a0 \u00a05432<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0432\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 SET_BIT \u043d\u0438\u043a\u043e\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435,\u00a0\u0441\u043a\u043e\u0440\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<h2>BIT_COUNT<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f BIT_COUNT \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>BIT_COUNT(\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435)<\/code><\/pre>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0438\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c, \u043d\u0435 LOB.\u00a0\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f BIGINT.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0435\u0430\u043d\u0441\u0430, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0441\u0435\u0430\u043d\u0441\u0435:<\/p>\n<pre><code class=\"sql\">SELECT BIT_COUNT ( \u00a0@@OPTIONS \u00a0) ;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441\u0435\u0430\u043d\u0441\u0435:<\/p>\n<pre><code>-------------------- 7<\/code><\/pre>\n<h2>LEFT_SHIFT \u0438 RIGHT_SHIFT<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>LEFT_SHIFT<\/strong>, \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <strong>&lt;&lt;<\/strong>, \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u0442 \u0431\u0438\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432 \u0432\u043b\u0435\u0432\u043e, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043d\u0443\u043b\u044f\u043c\u0438.\u00a0\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>LEFT_SHIFT(\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f)  \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &lt;&lt; \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c LOB.\u00a0\u0422\u0438\u043f \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435.\u00a0\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0441\u0434\u0432\u0438\u0433\u043e\u0432 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>RIGHT_SHIFT<\/strong>, \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <strong>>><\/strong> , \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0431\u0438\u0442\u043d\u044b\u0439 \u0441\u0434\u0432\u0438\u0433 \u0432\u043f\u0440\u0430\u0432\u043e \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u0438\u0442, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043d\u0443\u043b\u044f\u043c\u0438.\u00a0\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0442\u0443\u0442 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u0432\u0438\u0434\u0443\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Logical_shift\" rel=\"noopener noreferrer nofollow\">\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 (logical shift) \u0432\u043f\u0440\u0430\u0432\u043e<\/a>\u00a0, \u0430 \u043d\u0435\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Arithmetic_shift\" rel=\"noopener noreferrer nofollow\">\u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 (arithmetic shift) \u0432\u043f\u0440\u0430\u0432\u043e<\/a>, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 (MSB).\u00a0T-SQL \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 \u0432\u043f\u0440\u0430\u0432\u043e.\u00a0\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>RIGHT_SHIFT(\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435) \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 >> \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/code><\/pre>\n<p>\u0412 \u043e\u0431\u0435\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0431\u0438\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f (\u0438\u0441\u0445\u043e\u0434\u043d\u043e, \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u043b\u0435\u0432\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u0440\u0438 \u0441\u0434\u0432\u0438\u0433\u0435 \u0432\u043b\u0435\u0432\u043e \u0438\u043b\u0438 \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u0440\u0438 \u0441\u0434\u0432\u0438\u0433\u0435 \u0432\u043f\u0440\u0430\u0432\u043e).\u00a0\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u043a\u0430\u0436\u0435\u0442\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430, SQL Server \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.\u00a0\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, x<strong> >><\/strong> -1 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 x <strong>&lt;&lt; <\/strong>1.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0438\u0442\u044b \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 10 \u0441\u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043f\u0440\u0430\u0432\u043e \u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e:<\/p>\n<pre><code>SELECT 10 >> 1 AS rightshift, 10 &lt;&lt; 1 AS leftshift;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>rightshift\u00a0 leftshift ----------- ----------- 5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 20<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 INT-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 10 \u0432 \u0432\u0438\u0434\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>0000 0000 0000 0000 0000 0000 0000 1010<\/code><\/pre>\n<p>\u0421\u0434\u0432\u0438\u0433 \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043f\u0440\u0430\u0432\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<pre><code>0000 0000 0000 0000 0000 0000 0000 0101<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 5.<\/p>\n<p>\u0421\u0434\u0432\u0438\u0433 \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<pre><code>0000 0000 0000 0000 0000 0000 0001 0100<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 20.<\/p>\n<p>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430 \u043d\u0430 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0434\u0432\u0438\u0433 \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443, \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c val \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 n \u0431\u0438\u0442 \u0434\u0430\u0435\u0442 val\/2^n, \u0430 \u0441\u0434\u0432\u0438\u0433 \u0434\u043b\u044f val \u0432\u043b\u0435\u0432\u043e \u043d\u0430 n \u0431\u0438\u0442 \u0434\u0430\u0435\u0442 val*2^n.<\/p>\n<p>\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0432\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 T-SQL \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u044d\u043a\u0437\u043e\u0442\u0438\u043a\u0443 \u0441 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u043c\u0438 \u0441\u0434\u0432\u0438\u0433\u0430\u043c\u0438.\u00a0<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0430 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0441\u043a\u0430\u0445 \u0438\u0437-\u0437\u0430 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u044b\u0435 \u0431\u0438\u0442\u044b \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0432\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0440\u043e\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0438\u0442\u043e\u0432 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c perms BINARY(25) \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 dbo.UserRolePerms.\u00a0\u0421\u0442\u043e\u043b\u0431\u0435\u0446 \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043e 200 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u043e \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f 80 \u0431\u0438\u0442\u043e\u0432 \u0441\u043f\u0440\u0430\u0432\u0430 (\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 79) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f 80 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439.\u00a0\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f 10 \u043d\u043e\u0432\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439.\u00a0\u041f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043d\u0435\u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 10 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u0430\u0432\u044b\u0445 \u0431\u0438\u0442 (\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 9).\u00a0\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445 \u043d\u0430 10 \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e.<\/p>\n<pre><code class=\"sql\">UPDATE dbo.UserRolePerms SET perms = perms &lt;&lt; 10;<\/code><\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0431\u0438\u0442\u0430\u043c\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0449\u0435 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u0442\u0430\u043c\u0438, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0435\u0437 \u043d\u0438\u0445.<\/p>\n<h2>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0438\u0442\u0430 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u0438\u043b\u0438 \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0431\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u0431\u0435\u0437 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0438\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 @val \u0438 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 @offset.\u00a0\u0422\u0435\u0445\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 @val \u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0422\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 TINYINT \u0432 SQL Server \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430, \u0430 SMALLINT, INT \u0438 BIGINT \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u00ab<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%BE%D0%BF%D0%BE%D0%BB%D0%BD%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9_%D0%BA%D0%BE%D0%B4\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0432\u043e\u0435\u043a<\/a>\u00bb (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Two%27s_complement\" rel=\"noopener noreferrer nofollow\">two\u2019s complement<\/a>). \u0415\u0441\u043b\u0438 @val \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f TINYINT, SMALLINT, INT \u0438\u043b\u0438 BIGINT \u0441 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0435\u0439, \u0447\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0431\u0438\u0442 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0442 (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0431\u0438\u0442\u043e\u0432\u044b\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432 \u0442\u043e \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u043a \u0438 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 @val) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f @val <strong>&amp;<\/strong> <strong>POWER<\/strong>(2, @offset), \u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0438\u0442\u0430 (1 \u0438\u043b\u0438 0) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f SIGN(@val <strong>&amp;<\/strong> <strong>POWER<\/strong>(2, @offset)).\u00a0<\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">DECLARE @val AS INT = 5496, @offset AS INT = 6; SELECT \u00a0\u00a0@val &amp; POWER(2, @offset) AS bitval, \u00a0 SIGN(@val &amp; POWER(2, @offset)) AS bitstate;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>bitval\u00a0\u00a0\u00a0\u00a0\u00a0 bitstate ----------- ----------- 64\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1<\/code><\/pre>\n<p>\u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0434\u043b\u044f @val \u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043b\u0435\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430?\u00a0\u041e\u0431\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b \u0434\u043b\u044f \u043a\u0440\u0430\u0439\u043d\u0435\u0433\u043e \u043b\u0435\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430, \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0443\u0436\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"sql\">DECLARE @val AS INT = 5496, @offset AS INT = 31; SELECT \u00a0\u00a0@val &amp; POWER(2, @offset) AS bitval, \u00a0 SIGN(@val &amp; POWER(2, @offset)) AS bitstate;<\/code><\/pre>\n<blockquote>\n<p><em>Msg 232, Level 16, State 3, Line 3<br \/>Arithmetic overflow error for type int, value = 2147483648.000000.<\/em><\/p>\n<\/blockquote>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043d\u043e \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442 \u043a\u043e\u0434.<\/p>\n<p>\u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 @val \u0438\u043c\u0435\u0435\u0442 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0442\u0438\u043f BINARY(25)?\u00a0\u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043e\u0431\u0445\u043e\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<p>\u0417\u0430\u0442\u043e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0441\u0451 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e.\u00a0\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e GET_BIT \u0441 @val \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 @offset \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439.\u00a0\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 INT \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code>DECLARE @val AS INT = 5496, @offset AS INT = 31; SELECT GET_BIT( @val, @offset );<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0432\u043e\u0434, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u0447\u0442\u043e \u0431\u0438\u0442 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d:<\/p>\n<pre><code>----- 0<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 BINARY(25):<\/p>\n<pre><code class=\"sql\">DECLARE @val AS BINARY(25) = 0x9B3B9D5AD3084AB1A522082491B8519C008AB4AACB7064B037,  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0@offset AS INT = 100; SELECT GET_BIT( @val, @offset );<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0431\u0438\u0442 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d:<\/p>\n<pre><code>----- 1<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u0430, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e SET_BIT, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0431\u043d\u0443\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0431\u0438\u0442\u0430\u043c\u0438, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 @@offset, \u0430 \u0442\u0440\u0435\u0442\u0438\u0439 \u2014 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 GET_BIT.\u00a0\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c:<\/p>\n<pre><code class=\"sql\">DECLARE @val AS INT = 5496, @offset AS INT = 6; SELECT SET_BIT(0, @offset, GET_BIT( @val, @offset ));<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>----------- 64<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c BINARY(25):<\/p>\n<pre><code class=\"sql\">DECLARE @val AS BINARY(25) = 0x9B3B9D5AD3084AB1A522082491B8519C008AB4AACB7064B037,  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0@offset AS INT = 100; SELECT SET_BIT(CAST(0x AS BINARY(25)), @offset, GET_BIT( @val, @offset ));<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<pre><code>----------------------------------------------------- 0x000000000000000000000000100000000000000000000000000<\/code><\/pre>\n<p>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0435\u0441\u044c \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0442 \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.\u00a0\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043e\u0441\u043e\u0431\u044b\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438 \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c \u0432\u044b\u0448\u0435.\u00a0\u0412\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u0447\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 SQL Server 2022, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e SET_BIT.<\/p>\n<h2>\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0431\u0438\u0442<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0431\u0438\u0442, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438.\u00a0\u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c, \u0438 \u0432\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0431\u0438\u0442 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0447\u0438\u0441\u0435\u043b, \u0443\u043c\u0435\u044e\u0449\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 AND (&amp;) \u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442 COUNT.<\/p>\n<p>\u0412\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 GetNums, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435:<\/p>\n<pre><code class=\"sql\">CREATE FUNCTION dbo.GetNums(@low AS BIGINT = 1, @high AS BIGINT) RETURNS TABLE AS RETURN WITH \u00a0 L0 AS ( SELECT 1 AS c  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FROM (VALUES(1),(1),(1),(1),(1),(1),(1),(1), \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (1),(1),(1),(1),(1),(1),(1),(1)) AS D(c) ), \u00a0 L1 AS ( SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B ), \u00a0 L2 AS ( SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B ), \u00a0 L3 AS ( SELECT 1 AS c FROM L2 AS A CROSS JOIN L2 AS B ), \u00a0 Nums AS ( SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS rownum \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FROM L3 ) SELECT TOP(@high - @low + 1) \u00a0\u00a0 rownum AS rn, \u00a0 \u00a0@high + 1 - rownum AS op, \u00a0 \u00a0@low - 1 + rownum AS n FROM Nums ORDER BY rownum; GO<\/code><\/pre>\n<p>\u0410 \u0432\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0431\u0438\u0442, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f @val \u0441 \u0442\u0438\u043f\u043e\u043c INT, \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0431\u0438\u0442 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"sql\">DECLARE @val AS INT = 5496; SELECT COUNT(*) AS bitcount FROM dbo.GetNums(0, 30) AS N WHERE @val &amp; POWER(2, N.n) &lt;> 0;<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<pre><code>bitcount ----------- 7<\/code><\/pre>\n<p>\u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0439\u0434\u0443\u0442\u0441\u044f \u043d\u0435 \u0434\u0435\u0448\u0435\u0432\u043e.\u00a0\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043a\u0440\u0430\u0439\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0431\u0438\u0442 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c.\u00a0\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u043e\u0432\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0432 SQL Server 2022 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e BIT_COUNT:<\/p>\n<pre><code class=\"sql\">DECLARE @intval \u00a0AS \u00a0INT \u00a0= \u00a05496 , \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @binval \u00a0AS \u00a0BINARY ( 25 ) \u00a0= 0x9B3B9D5AD3084AB1A522082491B8519C008AB4AACB7064B037 ; SELECT BIT_COUNTl) AS cntintval, BIT_COUNTl) AS cntbinval;<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435:<\/p>\n<pre><code>cntintval\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cntbinval -------------------- -------------------- 7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 85<\/code><\/pre>\n<h2>\u0411\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0434\u0432\u0438\u0433 \u0431\u0438\u0442.\u00a0\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0432\u0430\u043c \u0434\u0430\u043d\u044b @val \u0438 @offset, \u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u0432\u043f\u0440\u0430\u0432\u043e \u0438\u043b\u0438 \u0432\u043b\u0435\u0432\u043e \u0431\u0438\u0442\u044b \u0432 @val \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f @offset.<\/p>\n<p>\u0414\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430 \u0432\u043f\u0440\u0430\u0432\u043e, \u0435\u0441\u043b\u0438 @val \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c c \u0442\u0438\u043f\u043e\u043c \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 INT), \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 @val <strong>\/ POWER<\/strong>(2, @offset).<\/p>\n<p>\u0414\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430 \u0432\u043b\u0435\u0432\u043e, \u0435\u0441\u043b\u0438 @val \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c c \u0442\u0438\u043f\u043e\u043c \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 INT), \u0438 \u0432\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u043b\u0435\u0432\u044b\u0435 \u0431\u0438\u0442\u044b @offset + 1 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f (\u0440\u0430\u0432\u043d\u044b 0), \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 @val <strong>* POWER<\/strong>(2 , @offset).\u00a0\u0412\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043b\u0438, \u043a\u043e\u0433\u0434\u0430 @val \u0438\u043c\u0435\u0435\u0442 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0442\u0438\u043f, \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0421 \u043d\u043e\u0432\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439:<\/p>\n<pre><code class=\"sql\">DECLARE @val AS INT = -1, @offset AS INT = 1; SELECT @val >> @offset AS rightshift, @val &lt;&lt; @offset AS leftshift;<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<pre><code>rightshift\u00a0 leftshift ----------- ----------- 2147483647\u00a0 -2<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 -1 \u0441 \u0442\u0438\u043f\u043e\u043c INT \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>1111 1111 1111 1111 1111 1111 1111 1111<\/code><\/pre>\n<p>\u0421\u0434\u0432\u0438\u0433 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<pre><code>0111 1111 1111 1111 1111 1111 1111 1111<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 2147483647.<\/p>\n<p>\u0421\u0434\u0432\u0438\u0433 \u0432\u043b\u0435\u0432\u043e \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<pre><code>1111 1111 1111 1111 1111 1111 1111 1110<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 -2.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0434\u043b\u044f T-SQL, \u043d\u043e \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 SQL Server \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u043c\u0435\u0441\u0442\u043d\u0430 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.\u00a0\u0414\u043e SQL Server 2022 \u0432 T-SQL \u0431\u044b\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0431\u0438\u0442\u0430\u043c\u0438, \u0447\u0442\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u043e\u0442 \u0432\u0430\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0430\u043a\u0440\u043e\u0431\u0430\u0442\u0438\u043a\u043e\u0439.\u00a0\u0412 SQL Server 2022 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0434\u0432\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0427\u0435\u0433\u043e \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0432 T-SQL \u0432 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u0442\u0430\u043a \u044d\u0442\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0445 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 AND, OR \u0438 XOR.\u00a0Oracle, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.\u00a0\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u043b\u0435\u043d\u043e\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u043e\u043b\u0435\u0439, \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u043e\u043b\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.\u00a0\u0414\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u0418\u041b\u0418 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0441\u043e\u043a \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0445 \u0440\u043e\u043b\u0435\u0439, \u0447\u043b\u0435\u043d\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c.<\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a T-SQL \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/695332\/\"> https:\/\/habr.com\/ru\/post\/695332\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>21 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f 2022 \u0433.\u00a0<a href=\"https:\/\/sqlperformance.com\/author\/itzikbengan\" rel=\"noopener noreferrer nofollow\">Itzik Ben-Gan<\/a> <\/p>\n<p>\u0412 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f T-SQL \u043d\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u0430 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0431\u0438\u0442\u043e\u0432\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e.\u00a0\u041c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0431\u043e\u0440 \u0444\u043b\u0430\u0433\u043e\u0432 (\u0434\u0430\/\u043d\u0435\u0442, \u0432\u043a\u043b\/\u0432\u044b\u043a\u043b, \u0438\u0441\u0442\u0438\u043d\u0430\/\u043b\u043e\u0436\u044c) \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0439 \u0438\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0435, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043b\u0430\u0433.\u00a0\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\/\u0440\u043e\u043b\u0438.\u00a0\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435.\u00a0\u0414\u0430\u0436\u0435 SQL Server \u0445\u0440\u0430\u043d\u0438\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0444\u043b\u0430\u0433\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435.\u00a0\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043f\u043b\u0430\u043d\u0430 set_options \u0438 required_cursor_options, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f      \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/relational-databases\/system-dynamic-management-views\/sys-dm-exec-plan-attributes-transact-sql\" rel=\"noopener noreferrer nofollow\">sys.dm_exec_plan_attributes.<\/a><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0435\u0430\u043d\u0441\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/options-transact-sql\" rel=\"noopener noreferrer nofollow\">@@OPTIONS<\/a><\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u00ab<a href=\"https:\/\/learn.microsoft.com\/ru-ru\/sql\/database-engine\/configure-windows\/configure-the-user-options-server-configuration-option?view=sql-server-ver16\" rel=\"noopener noreferrer nofollow\">user options<\/a>\u00bb\u00a0\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/columns-updated-transact-sql\" rel=\"noopener noreferrer nofollow\">COLUMNS_UPDATED<\/a>\u00a0, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0431\u044b\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/grouping-id-transact-sql\" rel=\"noopener noreferrer nofollow\">GROUPING_ID<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043e\u043a.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0442\u043e\u0433\u043e, \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u043b\u0430\u0433, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438\u043b\u0438 \u0441\u043d\u044f\u0442\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u043b\u0430\u0433\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u0444\u043b\u0430\u0433\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b, \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432, \u0441\u0434\u0432\u0438\u0433 \u0431\u0438\u0442\u043e\u0432 \u0432\u043b\u0435\u0432\u043e \u0438\u043b\u0438 \u0432\u043f\u0440\u0430\u0432\u043e \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>\u0414\u043e SQL Server 2022 \u0432 T-SQL \u0431\u044b\u043b\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0442\u0430\u043c\u0438.\u00a0\u0418\u043c\u0435\u043b\u0430\u0441\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-and-transact-sql\" rel=\"noopener noreferrer nofollow\">&amp; (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0418 \/ <u>bitwise AND)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-or-transact-sql\" rel=\"noopener noreferrer nofollow\">| (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0418\u041b\u0418 \/ <u>bitwise OR)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-exclusive-or-transact-sql\" rel=\"noopener noreferrer nofollow\">^ (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0435 \u0418\u041b\u0418 \/ <u>bitwise XOR)<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/language-elements\/bitwise-not-transact-sql\" rel=\"noopener noreferrer nofollow\">~ (\u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u041d\u0415 \/ <u>bitwise NOT)<\/u><\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0431\u0438\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0443\u0442\u0451\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.\u00a0\u041d\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0438 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u044e \u043b\u043e\u0433\u0438\u043a\u0435.<\/p>\n<p>SQL Server 2022 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0438\u0442\u0430\u043c\u0438, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u0445 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c\u0438.\u00a0\u041d\u0438\u0436\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b:\u00a0<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/get-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f GET_BIT<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/get-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">GET_BIT function<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/set-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f SET_BIT<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/set-bit-transact-sql\" rel=\"noopener noreferrer nofollow\">SET_BIT function<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/bit-count-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f BIT_COUNT<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/bit-count-transact-sql\" rel=\"noopener noreferrer nofollow\">BIT_COUNT function<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/left-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f LEFT_SHIFT \/ \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &lt;&lt;<\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/left-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">LEFT_SHIFT function \/ &lt;&lt; operator<\/a>)<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.microsoft.com\/ru-ru\/sql\/t-sql\/functions\/right-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f RIGHT_SHIFT \/ \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 >><\/a> (<a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/right-shift-transact-sql\" rel=\"noopener noreferrer nofollow\">RIGHT_SHIFT function \/ >> operator<\/a>)<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u0438\u0445 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435.\u00a0\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.\u00a0\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442 \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u0440\u0435\u0448\u0438\u0442\u044c.<\/p>\n<h2>GET_BIT \u0438 SET_BIT<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f GET_BIT \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0431\u0438\u0442 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0431\u0438\u0442\u043e\u0432\u044b\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>GET_BIT (\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435)<\/code><\/pre>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c (integer) \u0438\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c (binary, \u043d\u0435 LOB).\u00a0\u0411\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 0 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0431\u0438\u0442 \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0430\u043b\u0435\u0432\u043e.\u00a0\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0435 0 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e (\u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u043e\u0433\u043e) \u0431\u0438\u0442\u0430, 1 \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u2026, 31 \u0434\u043b\u044f \u0442\u0440\u0438\u0434\u0446\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.\u00a0\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f BIT.\u00a0\u042d\u0442\u043e 1, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u0438 0, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0435\u0430\u043d\u0441\u0430 ARITHABORT \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u0431\u0438\u0442 \u043f\u043e \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0435 \u0440\u0430\u0432\u043d\u044b\u043c 6, \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 @@options.\u00a0\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0438\u0436\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \u044d\u0442\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u0435\u0430\u043d\u0441\u0435:<\/p>\n<pre><code class=\"sql\">SELECT GET_BIT( @@OPTIONS, 6 );<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 ARITHABORT \u0432 \u0441\u0435\u0430\u043d\u0441\u0435 \u0431\u044b\u043b \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434:<\/p>\n<pre><code>----- 1<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f SET_BIT \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u0431\u0438\u0442 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 1 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043b\u0438 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (1 \u0438\u043b\u0438 0), \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043e.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>SET_BIT (\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 [, \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435])<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 GET_BIT.\u00a0\u0412\u0432\u043e\u0434 \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 (\u043d\u043e \u043e\u043d \u0442\u043e\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c 1 \u0438\u043b\u0438 0).<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0430\u043a \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 @@OPTIONS, \u0442\u0430\u043a \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c ARITHABORT:<\/p>\n<pre><code class=\"sql\">SELECT @@OPTIONS AS cursession, SET_BIT( @@OPTIONS, 6, 0 ) AS cursession_ARITHABORT_off;<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">cursession  cursession_ARITHABORT_off ----------- ------------------------- 5496 \u00a0\u00a0\u00a0\u00a0\u00a0 \u00a05432<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0432\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 SET_BIT \u043d\u0438\u043a\u043e\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435,\u00a0\u0441\u043a\u043e\u0440\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<h2>BIT_COUNT<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f BIT_COUNT \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438.\u00a0\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>BIT_COUNT(\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435)<\/code><\/pre>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0438\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c, \u043d\u0435 LOB.\u00a0\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f BIGINT.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0435\u0430\u043d\u0441\u0430, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0441\u0435\u0430\u043d\u0441\u0435:<\/p>\n<pre><code class=\"sql\">SELECT BIT_COUNT ( \u00a0@@OPTIONS \u00a0) ;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441\u0435\u0430\u043d\u0441\u0435:<\/p>\n<pre><code>-------------------- 7<\/code><\/pre>\n<h2>LEFT_SHIFT \u0438 RIGHT_SHIFT<\/h2>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>LEFT_SHIFT<\/strong>, \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <strong>&lt;&lt;<\/strong>, \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u0442 \u0431\u0438\u0442\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432 \u0432\u043b\u0435\u0432\u043e, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043d\u0443\u043b\u044f\u043c\u0438.\u00a0\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>LEFT_SHIFT(\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f)  \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &lt;&lt; \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c LOB.\u00a0\u0422\u0438\u043f \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u0438 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435.\u00a0\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0441\u0434\u0432\u0438\u0433\u043e\u0432 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>RIGHT_SHIFT<\/strong>, \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <strong>>><\/strong> , \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0431\u0438\u0442\u043d\u044b\u0439 \u0441\u0434\u0432\u0438\u0433 \u0432\u043f\u0440\u0430\u0432\u043e \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u0438\u0442, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043d\u0443\u043b\u044f\u043c\u0438.\u00a0\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0442\u0443\u0442 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u0432\u0438\u0434\u0443\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Logical_shift\" rel=\"noopener noreferrer nofollow\">\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 (logical shift) \u0432\u043f\u0440\u0430\u0432\u043e<\/a>\u00a0, \u0430 \u043d\u0435\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Arithmetic_shift\" rel=\"noopener noreferrer nofollow\">\u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 (arithmetic shift) \u0432\u043f\u0440\u0430\u0432\u043e<\/a>, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 (MSB).\u00a0T-SQL \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 \u0432\u043f\u0440\u0430\u0432\u043e.\u00a0\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<\/p>\n<pre><code>RIGHT_SHIFT(\u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435) \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 >> \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/code><\/pre>\n<p>\u0412 \u043e\u0431\u0435\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0431\u0438\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f (\u0438\u0441\u0445\u043e\u0434\u043d\u043e, \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u043b\u0435\u0432\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u0440\u0438 \u0441\u0434\u0432\u0438\u0433\u0435 \u0432\u043b\u0435\u0432\u043e \u0438\u043b\u0438 \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u044b\u0435 \u0431\u0438\u0442\u044b \u043f\u0440\u0438 \u0441\u0434\u0432\u0438\u0433\u0435 \u0432\u043f\u0440\u0430\u0432\u043e).\u00a0\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u043a\u0430\u0436\u0435\u0442\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430, SQL Server \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.\u00a0\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, x<strong> >><\/strong> -1 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 x <strong>&lt;&lt; <\/strong>1.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0438\u0442\u044b \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 10 \u0441\u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043f\u0440\u0430\u0432\u043e \u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e:<\/p>\n<pre><code>SELECT 10 >> 1 AS rightshift, 10 &lt;&lt; 1 AS leftshift;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0432\u044b\u0434\u0430\u0441\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>rightshift\u00a0 leftshift ----------- ----------- 5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 20<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 INT-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 10 \u0432 \u0432\u0438\u0434\u0435 \u0431\u0438\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>0000 0000 0000 0000 0000 0000 0000 1010<\/code><\/pre>\n<p>\u0421\u0434\u0432\u0438\u0433 \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043f\u0440\u0430\u0432\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<pre><code>0000 0000 0000 0000 0000 0000 0000 0101<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 5.<\/p>\n<p>\u0421\u0434\u0432\u0438\u0433 \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443:<\/p>\n<pre><code>0000 0000 0000 0000 0000 0000 0001 0100<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 20.<\/p>\n<p>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430 \u043d\u0430 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0434\u0432\u0438\u0433 \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443, \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c val \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 n \u0431\u0438\u0442 \u0434\u0430\u0435\u0442 val\/2^n, \u0430 \u0441\u0434\u0432\u0438\u0433 \u0434\u043b\u044f val \u0432\u043b\u0435\u0432\u043e \u043d\u0430 n \u0431\u0438\u0442 \u0434\u0430\u0435\u0442 val*2^n.<\/p>\n<p>\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0432\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 T-SQL \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u044d\u043a\u0437\u043e\u0442\u0438\u043a\u0443 \u0441 \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u043c\u0438 \u0441\u0434\u0432\u0438\u0433\u0430\u043c\u0438.\u00a0<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0430 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0441\u043a\u0430\u0445 \u0438\u0437-\u0437\u0430 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u044b\u0435 \u0431\u0438\u0442\u044b \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432.\u00a0\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0432\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0440\u043e\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0438\u0442\u043e\u0432 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c perms BINARY(25) \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 dbo.UserRolePerms.\u00a0\u0421\u0442\u043e\u043b\u0431\u0435\u0446 \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u043e 200 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u043e \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f 80 \u0431\u0438\u0442\u043e\u0432 \u0441\u043f\u0440\u0430\u0432\u0430 (\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 79) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f 80 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439.\u00a0\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f 10 \u043d\u043e\u0432\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439.\u00a0\u041f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043d\u0435\u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 10 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u0430\u0432\u044b\u0445 \u0431\u0438\u0442 (\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 9).\u00a0\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0445 \u043d\u0430 10 \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e.<\/p>\n<pre><code class=\"sql\">UPDATE dbo.UserRolePerms SET perms = perms &lt;&lt; 10;<\/code><\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0431\u0438\u0442\u0430\u043c\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0449\u0435 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u0442\u0430\u043c\u0438, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0435\u0437 \u043d\u0438\u0445.<\/p>\n<h2>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0438\u0442\u0430 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u0438\u043b\u0438 \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0431\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u0431\u0435\u0437 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0438\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 @val \u0438 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 @offset.\u00a0\u0422\u0435\u0445\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 @val \u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0422\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 TINYINT \u0432 SQL Server \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430, \u0430 SMALLINT, INT \u0438 BIGINT \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u00ab<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%BE%D0%BF%D0%BE%D0%BB%D0%BD%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9_%D0%BA%D0%BE%D0%B4\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0432\u043e\u0435\u043a<\/a>\u00bb (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Two%27s_complement\" rel=\"noopener noreferrer nofollow\">two\u2019s complement<\/a>). \u0415\u0441\u043b\u0438 @val \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f TINYINT, SMALLINT, INT \u0438\u043b\u0438 BIGINT \u0441 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0435\u0439, \u0447\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0431\u0438\u0442 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0442 (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0431\u0438\u0442\u043e\u0432\u044b\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432 \u0442\u043e \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u043a \u0438 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 @val) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f @val <strong>&amp;<\/strong> <strong>POWER<\/strong>(2, @offset), \u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0438\u0442\u0430 (1 \u0438\u043b\u0438 0) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f SIGN(@val <strong>&amp;<\/strong> <strong>POWER<\/strong>(2, @offset)).\u00a0<\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">DECLARE @val AS INT = 5496, @offset AS INT = 6; SELECT \u00a0\u00a0@val &amp; POWER(2, @offset) AS bitval, \u00a0 SIGN(@val &amp; POWER(2, @offset)) AS bitstate;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>bitval\u00a0\u00a0\u00a0\u00a0\u00a0 bitstate ----------- ----------- 64\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1<\/code><\/pre>\n<p>\u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0434\u043b\u044f @val \u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043b\u0435\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430?\u00a0\u041e\u0431\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b \u0434\u043b\u044f \u043a\u0440\u0430\u0439\u043d\u0435\u0433\u043e \u043b\u0435\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430, \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0443\u0436\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"sql\">DECLARE @val AS INT = 5496, @offset AS INT = 31; SELECT \u00a0\u00a0@val &amp; POWER(2, @offset) AS bitval, \u00a0 SIGN(@val &amp; POWER(2, @offset)) AS bitstate;<\/code><\/pre>\n<blockquote>\n<p><em>Msg 232, Level 16, State 3, Line 3<br \/>Arithmetic overflow error for type int, value =<\/em><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-340227","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340227"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340227\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}