博客统计信息

用户名:kaliking
文章数:34
评论数:77
访问量:113363
无忧币:487
博客积分:1140
博客等级:4
注册日期:2006-10-24

我的技术圈(1)

更多>>
SQL语句精选(SQL SERVER 2000)
2007-01-10 14:57:41
 
1.选择数据表中的字段明列表
SELECT name
FROM syscolumns
WHERE (id = OBJECT_ID('表名称'))
ORDER BY colorder
 
2.筛选重复数据
 
SN为出现重复的字段
 
非重复数据:   
  
select   a.*   from   表   a   where   not   exists(select   1   from   表   where   SN=a.SN   and   ID!=a.ID)  
 
    
    
  有重复数据:   
  
select   a.*   from   表   a   where   exists(select   1   from   表   where   SN=a.SN   and   ID!=a.ID)
 
 
3. 获取某个存储过程中的参数列表
select
      'Parameter_name'    = name,
      'Type'      = type_name(user_type_id),
      'Length'      = max_length,
      'Prec'      = case when type_name(system_type_id) = 'uniqueidentifier' then precision
        else OdbcPrec(system_type_id, max_length, precision) end,
      'Scale'      = OdbcScale(system_type_id, scale),
      'Param_order'  = parameter_id,
      'Collation'      = convert(sysname, case when system_type_id in (35, 99, 167, 175, 231, 239)
      then ServerProperty('collation') end)

  from sys.all_parameters where object_id = object_id('你的存储过程名称')
 
 
4. 在结果集上 添加 行号 (只适用于 sql 2005 ):
select *, row_number() over (order by [排序列]) as rownumber
from [表名]
 
5. 简单分页程序( 在 4 的基础上完成 )
select * from (select *, row_number() over (order by [排序列]) as rownumber
from [表名]) as tmp
WHERE RowNumber between 50 and 60;
 
N.等用到时再添加哈~~`
分享至
更多
一键收藏,随时查看,分享好友!
sml1012
1人
了这篇文章
类别:数据库技术圈()┆阅读()┆评论() ┆ 推送到技术圈返回首页

文章评论

 
2010-01-04 11:22:24
转载了此篇文章,谢谢!

2010-11-25 14:03:37
学习中!

 

发表评论            

【技术门诊】专家解析:软考重点难点及应试技巧
昵  称:
登录  快速注册
验证码:

请点击后输入验证码博客过2级,无需填写验证码

内  容: