SQL常用函数之三 REPLICATE () ?
按指定次数重复字符表达式。
语法
REPLICATE ( character_expression, integer_expression)
参数
character_expression
字符数据型的字母数字表达式,或者可以隐式转换为 nvarchar 或 ntext 的其他数据类型的字母数字表达式。
integer_expression
可以隐式转换为 int 的表达式。如果 integer_expression 为负,将返回空字符串。
返回值
nvarchar 或 ntext
1 :Select Replicate('abc',2) ----------------abcabc
2 :Select Replicate('abc',-2) ----------------null
3 :Select Replicate('abc',0)--------------- 无
相关文档:
今天打开企业管理器的时候提示“关于MMC不能打开文件C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQL Server Enterprise Manager.MSC可能是由于文件不存在,不是一个MMC控制台,或者用后来的MMC版本创建。也可能你没有访问此文件的足够权限”,google之,发 ......
[code]declare @startdt datetime
declare @enddt datetime
select @startdt='2009-12-03',@enddt='2009-12-05'
select * from tb
where 开始日期 between @startdt and @enddt
or 结束日期 between @startdt and @enddt
or @startdt between 开始日期 and 结束日期
or @enddt between 开始日期 and ......
作为一个B/S开发者,或多或少都得和数据库打交道,而对数据库的操作归根到底都是query语句,所有到最后都是为了查询,那么查看sql性能又成了我们开发中的一件趣事。下面简单介绍下sql_trace的使用:
alter session set sql_trace =true ;--打开sql_trace
select * from (select * from t order by id) where rownum <= ......
----查看所有角本
Create table #y (txt text)
select name, iid = identity(int,1,1) into #x from SysObjects where xtype = 'TR'
declare @i int, @max int
declare @name varchar(40)
set @i = 1
select @max = max(iid) from #x
while @i <= @max
begin
select @name = name from #x w ......