sql_server_action

 

 

 

'''
SELECT * FROM Info_Roles WHERE Flag=1 LIMIT 2;


 select   top   y   *   from   表   where   主键   not   in(select   top   (x-1)*y   主键   from   表)



  如果表中无主键,可以用临时表,加标识字段解决.这里的x,y可以用变量.

  select   id=identity(int,1,1),*     into   #tb   from   表
  select   *   from   #tb   where   id   between   (x-1)*y   and   x*y-1




 select   top   1000   Info_ID   from   Info_Roles
 select   top   2000   Info_ID,',xiaole20180410SPLIT,',content   from   Info_Content   where   Info_ID   not   in( select   top   1000   Info_ID   from   Info_Roles   )   ;
 select   top   399   Info_ID,',xiaole20180410SPLIT,',UPPER(content)   from   Info_Content      ;
 select   top   399   CHARINDEX('IMG',UPPER(content))   from   Info_Content      ;
 select   top   15   Info_ID,',xiaole20180410SPLIT,',content   from   Info_Content   where  CHARINDEX('IMG',UPPER(content))>0;
 select   top   15   Info_ID,',xiaole20180410SPLIT,',content   from   Info_Content   where
 Info_ID      in( select   top   1000   Info_ID   from   Info_Roles   )  and
  CHARINDEX('IMG',UPPER(content))>0
 ;



SELECT
	TOP 15 Info_ID,
	',xiaole20180410SPLIT,',
	content
FROM
	Info_Content
WHERE
	Info_ID IN (
		SELECT
			TOP 1000 Info_ID
		FROM
			Info_Roles
		WHERE
			Flag = 1
	)
AND CHARINDEX('IMG', UPPER(content)) > 0;





SELECT
	TOP 200 Info_ID,
	',xiaole20180410SPLIT,',
	content
FROM
	Info_Content
WHERE
	Info_ID IN (
		SELECT
			TOP 90000 Info_ID
		FROM
			Info_Roles
	)
AND CHARINDEX('<IMG', UPPER(content)) > 0;



'''

  

 

 

时间格式化查询

 


SELECT GETDATE();
SELECT DAY(GETDATE());
SELECT DAY(GETDATE());
SELECT convert(varchar, getdate(), 103) ; #10/05/2018

SELECT TOP 1 dateandtime FROM Info_Roles ;
SELECT TOP 1 convert(varchar, dateandtime, 103) FROM Info_Roles ;
SELECT TOP 10 * FROM Info_Roles WHERE convert(varchar, dateandtime, 103) = convert(varchar, getdate(), 103) ;

 

posted @ 2018-04-10 15:59  papering  阅读(290)  评论(0编辑  收藏  举报