Click here to Skip to main content
15,918,742 members
Home / Discussions / Database
   

Database

 
GeneralRe: Dynamic SQL Statements in Stored Procedure Pin
N a v a n e e t h8-Mar-07 20:09
N a v a n e e t h8-Mar-07 20:09 
GeneralRe: Dynamic SQL Statements in Stored Procedure Pin
Colin Angus Mackay8-Mar-07 21:26
Colin Angus Mackay8-Mar-07 21:26 
QuestionDateTime Problem Pin
sks838-Mar-07 2:50
sks838-Mar-07 2:50 
AnswerRe: DateTime Problem Pin
N a v a n e e t h8-Mar-07 3:04
N a v a n e e t h8-Mar-07 3:04 
AnswerRe: DateTime Problem Pin
Hayder Marzouk8-Mar-07 21:56
Hayder Marzouk8-Mar-07 21:56 
QuestionClient - Server Pin
alav8-Mar-07 1:56
alav8-Mar-07 1:56 
AnswerRe: Client - Server Pin
Pete O'Hanlon8-Mar-07 2:06
mvePete O'Hanlon8-Mar-07 2:06 
QuestionPIVOT in SQL 2005 problem Pin
Håkan Nilsson (k)8-Mar-07 0:20
Håkan Nilsson (k)8-Mar-07 0:20 
I'm trying to use PIVOT instead of CASE but can't make it, what's wrong with the pivot query below?

create table t1 (a int, b char(5))
go
insert t1 values(1, 'SVE')
insert t1 values(1, 'FIN')
insert t1 values(1, 'DAN')
insert t1 values(2, 'SVE')
insert t1 values(2, 'FIN')
insert t1 values(3, 'SVE')

select * from t1

a b
----------- -----
1 SVE
1 FIN
1 DAN
2 SVE
2 FIN
3 SVE

(6 row(s) affected)

-- SQL 2000 with case works
select a,
max(case when b='SVE' then b else '' end) as b_sve,
max(case when b='FIN' then b else '' end) as b_fin,
max(case when b='DAN' then b else '' end) as b_dan
from t1
group by a

a b_sve b_fin b_dan
----------- ----- ----- -----
1 SVE FIN DAN
2 SVE FIN
3 SVE

(3 row(s) affected)

-- SQL 2005 with pivot, this select doesn't work!
select a,
isnull(['SVE'], '') as b_sve,
isnull(['FIN'], '') as b_fin,
isnull(['DAN'], '') as b_dan
from (select a, b from t1) p
pivot (
max(b) for b in ( ['SVE'], ['FIN'], ['DAN'] )
) pvt;

a b_sve b_fin b_dan
----------- ----- ----- -----
1
2
3

(3 row(s) affected)


Håkan Nilsson
-- Swedish developer, DBA, C#, SQL Server, soccer trainer, old C64 player

Questionoleobject in sql oracle mysql Pin
nikhil12347-Mar-07 22:35
nikhil12347-Mar-07 22:35 
AnswerRe: oleobject in sql oracle mysql Pin
Colin Angus Mackay8-Mar-07 0:08
Colin Angus Mackay8-Mar-07 0:08 
QuestionRegarding Video files Pin
praveen_gattu20007-Mar-07 21:22
praveen_gattu20007-Mar-07 21:22 
AnswerRe: Regarding Video files Pin
Paddy Boyd8-Mar-07 0:00
Paddy Boyd8-Mar-07 0:00 
AnswerRe: Insert Problem Pin
_anil_7-Mar-07 21:02
_anil_7-Mar-07 21:02 
GeneralRe: Insert Problem Pin
Colin Angus Mackay8-Mar-07 0:10
Colin Angus Mackay8-Mar-07 0:10 
Questionproblem on on date filtering Pin
firestoper7-Mar-07 19:45
firestoper7-Mar-07 19:45 
AnswerRe: problem on on date filtering Pin
andyharman7-Mar-07 22:40
professionalandyharman7-Mar-07 22:40 
GeneralRe: problem on on date filtering Pin
firestoper7-Mar-07 22:53
firestoper7-Mar-07 22:53 
GeneralRe: problem on on date filtering Pin
Pete O'Hanlon8-Mar-07 0:45
mvePete O'Hanlon8-Mar-07 0:45 
GeneralRe: problem on on date filtering Pin
andyharman8-Mar-07 1:38
professionalandyharman8-Mar-07 1:38 
AnswerRe: problem on on date filtering Pin
Harini N K7-Mar-07 23:59
Harini N K7-Mar-07 23:59 
QuestionAuto database connection when SQL Server 2005 restarts Pin
zxc897-Mar-07 18:43
zxc897-Mar-07 18:43 
Questioncommunicating SQL server with DB2 Pin
ajit zamindar7-Mar-07 18:34
ajit zamindar7-Mar-07 18:34 
QuestionDatabase contention Pin
Darkness847-Mar-07 11:56
Darkness847-Mar-07 11:56 
AnswerRe: Database contention Pin
Dave Kreskowiak7-Mar-07 12:30
mveDave Kreskowiak7-Mar-07 12:30 
GeneralRe: Database contention Pin
Darkness847-Mar-07 12:38
Darkness847-Mar-07 12:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.