随笔分类 -  sql

摘要:https://blog.csdn.net/yuxuac/article/details/79204910 1.查询表行数 SELECT object_name (i.id) TableName, rows as RowCnt FROM sysindexes i INNER JOIN sysObje 阅读全文
posted @ 2019-12-24 10:41 Ace001 阅读(1927) 评论(0) 推荐(0)
摘要:1.取时间最新的记录 不分组有重复(多条CreateTime一样的都是最新记录) select * from test t where pid in ( select PId from Test t where time=(select max(time) from Test t1 where t1 阅读全文
posted @ 2019-12-04 10:28 Ace001 阅读(25774) 评论(1) 推荐(4)
摘要:update table set photo=(SELECT * FROM OPENROWSET(BULK N'D:\no.png', SINGLE_BLOB) as Photo) From:https://www.cnblogs.com/xuejianxiyang/p/11225577.html 阅读全文
posted @ 2019-07-22 14:17 Ace001 阅读(3103) 评论(0) 推荐(0)
摘要:Time字段以小时分组统计 select datepart(hour,time) hour,count(1) count from table where Similarity<75 group by datepart(hour,time) order by count desc From:http 阅读全文
posted @ 2019-07-17 18:39 Ace001 阅读(13546) 评论(0) 推荐(0)
摘要:打开cmd执行(d:\script.sql为sql文件位置): sqlcmd -S 127.0.0.1 -U sa -P sa -i d:\script.sql From:https://www.cnblogs.com/xuejianxiyang/p/9234781.html 阅读全文
posted @ 2018-06-27 16:48 Ace001 阅读(4803) 评论(0) 推荐(0)
摘要:with #pager as (select * ,ROW_NUMBER() OVER(Order By ID) as rowid from table)select * from #pager where rowid between (130 * (50-1)+1) and 130 * 50 -- 阅读全文
posted @ 2018-01-23 09:09 Ace001 阅读(158) 评论(0) 推荐(0)
摘要:要实现join字符串 select * FROM table1 as t1 right join (select '1,2,3,4,5' as t) as tt on t1.Id=tt.t 则需要分割字符串为数组,以下为实现的分割字符串函数split split函数及使用示例: select * F 阅读全文
posted @ 2017-06-16 09:38 Ace001 阅读(4875) 评论(0) 推荐(0)
摘要:/* 获取字符串数组的 Table www.cnblogs.com/xqhppt/p/4377757.html*/ if exists (select 1 from sysobjects where id = object_id('split' )) drop Function splitgoCRE 阅读全文
posted @ 2017-06-15 17:17 Ace001 阅读(2170) 评论(0) 推荐(0)
摘要:直接分离附加是不行的. 操作步骤如下: 在sqlserver2008企业管理器中 右键xx数据库->任务->生成脚本 弹出框中勾选 为所选数据库中的所有对象编写脚本 下一步 修改如下图片提示部分 一路下一步,直到所有创建表结构语句与数据插入语句出现在查询分析器中, 拷贝查询分析器中的sql语句到sq 阅读全文
posted @ 2017-04-11 17:28 Ace001 阅读(1167) 评论(0) 推荐(0)
摘要:group by 的select 列明如果提示重复 记得as起别名 select name from (SELECT name,count(name) as countFROM Table WHERE (OrgUUId = (select top 1 uuid from org where orgn 阅读全文
posted @ 2016-04-14 15:41 Ace001
摘要:转自:http://blog.csdn.net/wangzh300/article/details/7382506 private static void DataTableToSQLServer( DataTable dt) { string connectionString = GetConnectionString(); ... 阅读全文
posted @ 2015-06-13 16:47 Ace001 阅读(368) 评论(0) 推荐(0)