Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Browsing all 3160 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

实例讲解sql server排名函数DENSE_RANK的用法

一、需求  之前sql server 的排名函数用得最多的应该是RoW_NUMBER()了,我通常用ROW_NUMBER() + CTE 来实现分页;今天逛园,看到另一个内置排名函数还不错,自己顺便想了一个需求,大家可以花1分钟先想想要怎么实现。  需求很简单:求成绩排名前五的学生信息。  例如:    由于成绩可以并列,所以前五名可能有多个。例如:      测试数据:  declare @t...

View Article


sql server如何利用开窗函数over()进行分组统计

这是一道常见的面试题,在实际项目中经常会用到。需求:求出以产品类别为分组,各个分组里价格最高的产品信息。实现过程如下:declare @t table(ProductID int,ProductName varchar(20),ProductType varchar(20),Price int)--测试数据insert @tselect 1,'name1','P1',3 union...

View Article


SQLServer行列互转实现思路(聚合函数)

有时候会碰到行转列的需求(也就是将列的值作为列名称),通常我都是用 CASE END + 聚合函数来实现的。如下:declare @t table(StudentName nvarchar(20), Subject nvarchar(20), Score int) Insert into @t (StudentName,Subject,Score) values ( '学生A', '中文', 80...

View Article

Image may be NSFW.
Clik here to view.

SQL Server 2016的数据库范围内的配置详解

SQL Server 2016真的让人眼前一亮。几天前微软就提供了RCO(候选发布版)版本的下载。我已经围观了一圈RCO版本,其中一个最拽的功能是数据库范围内的配置(Database Scoped...

View Article

Image may be NSFW.
Clik here to view.

SQL Server数据类型转换方法

在SQL Server日常的函数、存储过程和SQL语句中,经常会用到不同数据类型的转换。在SQL Server有两种数据转换类型:一种是显性数据转换;另一种是隐性数据转换。下面分别对这两种数据类型转换进行简要的说明:1 显式转换显示转换是将某种数据类型的表达式显式转换为另一种数据类型。常用的是CAST 和 CONVERT 函数。 CAST: CAST ( expression AS...

View Article


Image may be NSFW.
Clik here to view.

SQL语句性能优化(续)

上篇介绍了一下自己在项目中遇到的一种使用sql语句的优化方式(性能优化――SQL语句),但是说的不够完整。在对比的过程中,没有将max函数考虑在内,经人提醒之后赶紧做了一个测试,测试过程中又学到了不少的东西。上次用的是select count(*) 和select *...

View Article

SQL2005查看死锁存储过程sp_who_lock

下面是我整理的监控sql server数据库,在性能测试过程中是否出现死锁、堵塞的SQL语句,还算比较准备,留下来备用。调用方法:选中相应的数据库,执行exec sp_who_lockUSE [master]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE procedure [dbo].[sp_who_lock] as begin...

View Article

Image may be NSFW.
Clik here to view.

What's New in SQL Server Integration Services 2016 - Part 1

By:Koen Verbeeck || Related Tips:More >SQL Server 2016 Problem SQL Server 2016 has been released to General Availability (GA) in June 2016. This release comes packed with dozens of new features and...

View Article


Image may be NSFW.
Clik here to view.

Technique to Set SQL Server Long Running Transaction Alert

Long-Running transaction in SQL Server is one of the main reasons behind the log filling up. This transaction makes the log remain active from the virtual log file containing start of the transaction....

View Article


Image may be NSFW.
Clik here to view.

Learn About SQL Server Master Data Services 2016

SQL Server 2016 comes up with the new release of Master Data Services (MDS). In it, some new features have been added to improve its performance. It helps the database administrators to manage the...

View Article

Speaking at SQL Server Geeks Annual Summit 2016

I am very happy and proud to share the news that I will be speaking in SQL Server Geeks Annual Summit 2016 to be held in Bangalore from Aug 11 to 13th. SQL Server Geeks Annual Summit is the biggest...

View Article

Monitor Query Performance

Blog post #7 in support of Tim Ford’s ( b | t ) #iwanttohelp, #entrylevel. Read about it here. Sooner or later when you’re working with SQL Server, someone is going to complain that the server is...

View Article

Image may be NSFW.
Clik here to view.

Stop an SSIS Package

There are several ways to stop and executing SSIS package. If the package is executing in the SSIS Catalog, you can use the SSISDB.[catalog].stop_operation stored procedure. Stop_operation has one...

View Article


Image may be NSFW.
Clik here to view.

SQL Server 2016 FK operator bug?

I recently read an a blog on MSDN that covered new features for the query optimizer in SQL Server 2016. One of the topics covered was a new operator for foreign key checks. This new operator certainly...

View Article

Image may be NSFW.
Clik here to view.

SQL Server Delete Duplicate Rows

There can be two types of duplication of rows in a table 1. Entire row getting duplicated because there is no primary key or unique key. 2. Only primary key or unique key value is different, but...

View Article


Image may be NSFW.
Clik here to view.

SQL SERVER System Stored Procedures I Use to Get Started

Call me an old school or whatever there are certain things I believe in strongly. I have a working style and these in my opinion have evolved over the years. I keep innovating myself as I learn on my...

View Article

Image may be NSFW.
Clik here to view.

SQL Server DBCC CHECKDB Overview

By:Brady Upton || Related Tips:More > Database Consistency Checks DBCCs Problem SQL Server database corruption can be a problem and can cause serious damage to a database. If youre an experienced...

View Article


Image may be NSFW.
Clik here to view.

Transforming Cartesian Coordinates to Spherical Coordinates in SQL Server...

Problem I need to transform Cartesian coordinate data in a SQL Server table to spherical coordinates. How can I do this in T-SQL? Solution During a recent research project working with triaxial...

View Article

Image may be NSFW.
Clik here to view.

SQL Server 2016 Automated Installs and a SQL 2016 Webinar

SQL Server 2016 Automated Installs and a SQL 2016Webinar July 26, 2016 Leave a comment I hate installing things through a GUI I’ve talked about this before at PASS Summit, and when I worked at big...

View Article

Image may be NSFW.
Clik here to view.

PowerSQL Get SQL TraceFlag SQL Service and Config Information

Get SQL Server configuration, service info, start type along with enabled Trace Flags of local or remote servers. This script outputs sql server configuration, service, start type, Service Account...

View Article
Browsing all 3160 articles
Browse latest View live