sqlserver2012数据库一点总结

1.upper()函数lower()完成字符串大小写的转换

eg. select * from article where upper(title) like '%'+upper(@title)+'%';

2.使用Order by newid()返回随机数据

eg. select top 10 * from word w_rank = 1 order by newid()

3.sql server生成随机数(转载:http://blog.sina.com.cn/s/blog_49b531af0100o2e1.html)

  1. sqlserver虽然有rand()函数可以用,但单纯用rand()来获取随机数有很多限制,因为rand()生成的是类似0.747589267212168随机小数,灵活处理一下就可以得到整数   
  2. select cast(ceiling(rand() N) as int) --生成的数是N以内的证书   
  3. select cast(ceiling(rand(checksum(newid()))*N) as int这个同上,但在批量操作时往往这个会更有用,如   
  4. update table set field=cast(ceiling(rand() *5 as int和update table set field=cast(ceiling(rand(checksum(newid()))*N) as int)产生的效果就完全不同,前者虽然也是生成随机数了,但是所有table表里的field字段的数值都是一样的,而后者就各不相同,原理就是1是先生成随机数,然后再更新,2是更新每条记录前生成随机数。   
  5. 将上面俩条语句中的ceiling换成floor就可以生成包含0的整数随机数。
4.sqlserver常用函数(http://www.cnblogs.com/supermy/articles/532098.html)
5. sqlserver字符串常用函数(http://www.cnblogs.com/kissdodog/p/3141361.html)

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...