Simon's SQL

SQL,DBA,tuning,Trouble Shooting,Performance

Archive for March, 2011

concatenate string value in SQL

Posted by Simon Cho on 03/08/2011

Hi all,

Have you ever need a concatenation string function for group by clause?

Here is the solution.

And I like this process.


set nocount on;

if OBJECT_ID(‘test’) is not null

drop table test


create table test


i int identity(1,1)

,c varchar(255)



insert into test (c)

select ‘a’

union all

select ‘b’

go 100

select i%2, replace(replace(max(b.list),,),,) as sum_c

from test a

cross apply (

select c + ‘,’ as c

from test

where i%2 = a.i%2

for xml path()

) b (list)

group by a.i%2



Posted in Common | Tagged: , , , | Leave a Comment »

First article

Posted by Simon Cho on 03/07/2011

Hi all,

This is my first blog for publishing SQL article.

I’ll update SQL stuff here.


Posted in Common | Leave a Comment »

MSDN Technical Articles for SQL servers.

Posted by Simon Cho on 03/07/2011

<SQL 2008 R2>

<SQL 2008>

<SQL 2005>

Posted in Common | Tagged: , , | Leave a Comment »

all information about SQL “Memory To Leave” area (also called MTL or “Memory To Reserve”).

Posted by Simon Cho on 03/07/2011

The Database Administrator’s Guide to the SQL Server Database Engine .NET Common Language Runtime Environment

If you use linked server queries, you need to read this….

How It Works: DBCC MemoryStatus Locked Pages Allocated and SinglePageAllocator Values

I had log backup jobs setup which started to fail intermittently for last couple of weeks. The SQL server complained of “insufficient system memory”. The jobs were backed up as part of maintenance plan – maxtransfersize option

How to find who is using / eating up the Virtual Address Space on your SQL Server

VirtualAlloc Function

SQL Server encounters memory pressure and generate 701 Error due to incorrect configuration of Service Broker

SQLOS’s memory manager and SQL Server’s Buffer Pool


Fix for “Failed Virtual Allocate Bytes” error? – Service Broker problem

FIX: Error message when you use SQL Server Service Broker in SQL Server 2005: “Failed Virtual Allocate Bytes: FAIL_VIRTUAL_RESERVE 589824”;en-us;959007

INF: Using DBCC MEMORYSTATUS to Monitor SQL Server Memory Usage

Server Memory Options

Various memory errors are logged to SQL Server error log when using SQL CLR objects

FIX: The memory usage of a SQL Server service increases quickly when you run a query that uses a linked server in SQL Server 2005 or in SQL Server 2008

AppDomain marked for unload due to memory pressure- Jonathan Kehayias

help with this AppDomain event- Jonathan Kehayias

SQL Server 2005: CLR Integration

Using the SQL Server Service Startup Options

Come on 64bit so we can leave the mem…. – Bob Ward


Simon Cho

Posted in Common | Tagged: , , , , | 2 Comments »