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

推荐订阅源

Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
J
Java Code Geeks
L
LangChain Blog
V
V2EX
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
博客园 - 司徒正美
B
Blog
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - 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