1、普通索引和聚集索引的区别2、以下语句是找出24岁的记录,其中Bitrhday已建索引,请问以下两条语句中,哪条效率更高?
(1)、select * from MemberBaseInfo where Birthday <= dateadd(year, -24, getdate()) and Birthday > dateadd(year, -25, getdate())
(2)、select * from MemberBaseInfo where datediff(year, Birthday, getdate())=243、写出存储过程和触发器的创建格式
(1)、select * from MemberBaseInfo where Birthday <= dateadd(year, -24, getdate()) and Birthday > dateadd(year, -25, getdate())
(2)、select * from MemberBaseInfo where datediff(year, Birthday, getdate())=243、写出存储过程和触发器的创建格式
(1)、select * from MemberBaseInfo where Birthday <= dateadd(year, -24, getdate()) and Birthday > dateadd(year, -25, getdate())
(2)、select * from MemberBaseInfo where datediff(year, Birthday, getdate())=24 --这个快
创建存储过程,存储过程是保存起来的可以接受和返回用户提供的参数的 Transact-SQL 语句的集合。可以创建一个过程供永久使用,或在一个会话中临时使用(局部临时过程),或在所有会话中临时使用(全局临时过程)。也可以创建在 Microsoft® SQL Server™ 启动时自动运行的存储过程。语法
CREATE PROC [ EDURE ] procedure_name [ ; number ]
[ { @parameter data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ] [ WITH
{ RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ] [ FOR REPLICATION ] AS sql_statement [ ...n ]
创建触发器,触发器是一种特殊的存储过程,在用户试图对指定的表执行指定的数据修改语句时自动执行。Microsoft® SQL Server™ 允许为任何给定的 INSERT、UPDATE 或 DELETE 语句创建多个触发器。语法
CREATE TRIGGER trigger_name
ON { table | view }
[ WITH ENCRYPTION ]
{
{ { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] }
[ WITH APPEND ]
[ NOT FOR REPLICATION ]
AS
[ { IF UPDATE ( column )
[ { AND | OR } UPDATE ( column ) ]
[ ...n ]
| IF ( COLUMNS_UPDATED ( ) { bitwise_operator } updated_bitmask )
{ comparison_operator } column_bitmask [ ...n ]
} ]
sql_statement [ ...n ]
}
}