SQL位运算
SQL位运算
select 2|8 --10
select 2|8|1 --11
select 10&8 --8,包含,10=8+2
select 10&2 --2,包含,10=2+8
select 10&4 --0,不包含
select 19&16 --16,包含,19=16+2+1
select 19&8 --0,包含,19=16+2+1
select * from SqlBitOperation where FBitTags&4=4
在权限中的应用
1、两张表
(1)、操作与权限标志表
if exists (select * from sysobjects where id = OBJECT_ID('[RightTags]') and OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE [RightTags]
CREATE TABLE [RightTags] (
[Pkid] [int] IDENTITY (1, 1) NOT NULL,
[RightsName] [nvarchar] (50) NOT NULL,
[RightsTag] [int] NOT NULL DEFAULT (0))
ALTER TABLE [RightTags] WITH NOCHECK ADD CONSTRAINT [PK_RightTags] PRIMARY KEY NONCLUSTERED ( [Pkid] )
SET IDENTITY_INSERT [RightTags] ON
INSERT [RightTags] ([Pkid],[RightsName],[RightsTag]) VALUES ( 1,'吃饭',1)
INSERT [RightTags] ([Pkid],[RightsName],[RightsTag]) VALUES ( 2,'拉屎',2)
INSERT [RightTags] ([Pkid],[RightsName],[RightsTag]) VALUES ( 3,'打炮',4)
INSERT [RightTags] ([Pkid],[RightsName],[RightsTag]) VALUES ( 4,'泡妞',8)
INSERT [RightTags] ([Pkid],[RightsName],[RightsTag]) VALUES ( 5,'生子',16)
INSERT [RightTags] ([Pkid],[RightsName],[RightsTag]) VALUES ( 6,'包二奶',32)
SET IDENTITY_INSERT [RightTags] OFF
(2)、用户与权限表
if exists (select * from sysobjects where id = OBJECT_ID('[RightUsers]') and OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE [RightUsers]
CREATE TABLE [RightUsers] (
[Pkid] [int] IDENTITY (1, 1) NOT NULL,
[FUser] [nvarchar] (50) NOT NULL,
[UserRights] [int] NOT NULL DEFAULT (0))
ALTER TABLE [RightUsers] WITH NOCHECK ADD CONSTRAINT [PK_RightUsers] PRIMARY KEY NONCLUSTERED ( [Pkid] )
SET IDENTITY_INSERT [RightUsers] ON
INSERT [RightUsers] ([Pkid],[FUser],[UserRights]) VALUES ( 1
相关文档:
1.按姓氏笔画排序:
Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.数据库加密:
select encrypt('原始密码')
select pwdencrypt('原始密码')
select pwdcompare('原始密码','加密后密码') = 1--相同;否则不相同 encrypt('原始密码')
select pwdencrypt('原始密码')
select pw ......
Sql Server2005的一个新特性便是我等了很久的Row_Number(),以前用Oracle时用rownumber写分页存储过程很方便:)
下面是我做的一个小小的测试,测试我原来在sql server2000下所用的分页存储过程与使用Row_Number()编写的存储过程在Sql Server2005上的执行效率...
数据表:
REATE TABLE [dbo].[test](
[UserId] [int] Pri ......
SQL2000的数据类型及长度
==============================
bigint 8
binary 8000
bit 1
char 8000
datetime 8
decimal 17
float 8
image 16
int 4
money 8
nchar 8000
ntext 16
numeric 17
nvarchar 8000
real 4
smalldatetime 4
smallint 2
smallmoney 4
sql_variant 8016
sysname 256
text 16
tim ......
for ACCESS :
update a, b set a.name=b.name1 where a.id=b.id
for SQL Server:
"update a set a.name=b.name1 from a,b where a.id=b.id"
update a set a.status=b.status
from table1 a,table2 b
&nbs ......
原网站无法访问,故保留google快照
How things work :
SQL
Select
Statement
Introduction
:
Ever asked your self how things work inside the
SQL
Select
statement? In this article we won’t be talking about how to writeSQL
Select
statem ......