惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏
B
Blog
小众软件
小众软件
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
L
LangChain Blog
WordPress大学
WordPress大学
罗磊的独立博客
GbyAI
GbyAI
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
美团技术团队
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog

博客园 - Jacky Xu

Office Excel Add-ins installation for AX 2012 and Dynamics AX 2012 clients reinstalltion Develop a Dynamics AX2012 Report by Visual Studio 2010 Codes Permission Management in AX 2012 Publish AX reports in AX2012 + SQL2008 Create a security policy in Dynamics AX2012 How to use a shared configuration file& Security configuration example in Dynamics AX 2012 Security management in Dynamics AX 2012 Dynamics AX2012 Installation& AOS (Cluster) configuration on Windows 7 Office 2007 Re-installed issue Delete printer sessions on Terminal server for users Launch AX2012 Virtual Machine Change Tracking -- SQL Server 2008 new feature FILESTREAM -- SQL Server2008 New Feature Don't use SQL keyword as your feild name of a table Reports development in Axapta 3 终端服务器许可问题 Can't access maintenance plan because Agent XPs component is turned off as part of the security configuration on sql2005 SQL Error log/Event ID(17890): A significant part of sql server process memory has been paged out. This may result.... command命令大全(转自http://blog.dhedu.gov.cn/u/72/archives/2009/14290.html)
记忆一些SQL语句
Jacky Xu · 2010-09-10 · via 博客园 - Jacky Xu

1, Select 50 unit unique records

select distinct  top 50 SalesId from salesline

2, Select total amount > 1500 records

select salesid,sum(amount) from salesline group by salesid having sum(amount)>1500

3, Define temporary table

create table #SalesCustom (UserName varchar(30), CustName varchar(30), EmpName varchar (30), Location varchar (30))

4, Insert data and join in

insert into #SalesCustom (UserName,CustName, EmpName, Location)

select CustName, salesid, EmpName, Location from salestable

inner join CustTable on salestable.custnumber= custtable.custnumber

inner join EmpTable on salestable.EmpId = EmpTable.EmpId

inner join Address on Address.Id = EmpTable.AddressId

5, sp_MSforeachtable: Check maximal RecId  in db on all tables (most tables has a RecId field)

create table #TT (tablename varchar(30), maxrecid int, minrecid int)
exec sp_MSforeachtable
      'insert into #TT select ''?'', max(recid),min(recid) from ? with(nolock)
select * from #TT order by maxecId desc
drop table #TT

6, update and datediff function

update #Issuehistory set #Issuehistory.Resolution = datediff(day,CreatedDate,CompletedDate),#Issuehistory.afield ='XXX' from #Issuehistory

7, exclusion weekday function

USE [DB_Name]
GO
/****** Object:  UserDefinedFunction [dbo].[DatePartWeekend]    Script Date: 09/10/2010 15:21:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create  function   [dbo].[DatePartWeekend](@BegTime   datetime,   @EndTime   datetime)
returns   int
as
begin
declare   @re   int
set   @re=0
while   @BegTime <=@EndTime
begin
select   @re=@re+1   where   (datepart(weekday,   @BegTime)+@@datefirst-1)%7   between   1   and   5
set   @BegTime=dateadd(day,   1,   @BegTime)
end

return   @re
end

8, 行列转换

Create table TT(part varchar(20), xu int )

插入

part      xu

a    null

a    null

a    null

a    null

b    null

b    null

b    null

c    null

执行:

select part,
xu=row_number() over(partition by part order by getdate())
from TT

结果:

a          1
a          2
a          3
a          4
b          1
b          2
b          3
c          1