Click here to Skip to main content
15,867,968 members
Home / Discussions / Database
   

Database

 
GeneralRe: how a data base file works Pin
RussellT13-Dec-22 12:29
professionalRussellT13-Dec-22 12:29 
QuestionOLE DB provider Pin
suren ramakrishnan18-Aug-22 21:16
suren ramakrishnan18-Aug-22 21:16 
AnswerRe: OLE DB provider Pin
Richard MacCutchan18-Aug-22 21:31
mveRichard MacCutchan18-Aug-22 21:31 
AnswerRe: OLE DB provider Pin
RedDk19-Aug-22 13:14
RedDk19-Aug-22 13:14 
QuestionReplacing back-end MS-ACCESS with SQL SERVER Pin
Nick Katditsik7-Aug-22 4:00
Nick Katditsik7-Aug-22 4:00 
AnswerRe: Repacing back-end MS-ACCESS with SQL SERVER Pin
Mycroft Holmes7-Aug-22 12:44
professionalMycroft Holmes7-Aug-22 12:44 
GeneralRe: Repacing back-end MS-ACCESS with SQL SERVER Pin
Nick Katditsik8-Aug-22 5:42
Nick Katditsik8-Aug-22 5:42 
AnswerRe: Repacing back-end MS-ACCESS with SQL SERVER Pin
Richard Deeming7-Aug-22 21:50
mveRichard Deeming7-Aug-22 21:50 
GeneralRe: Replacing back-end MS-ACCESS with SQL SERVER Pin
Nick Katditsik17-Aug-22 5:07
Nick Katditsik17-Aug-22 5:07 
GeneralRe: Replacing back-end MS-ACCESS with SQL SERVER Pin
Craig Robbins17-Aug-22 6:53
Craig Robbins17-Aug-22 6:53 
AnswerRe: Replacing back-end MS-ACCESS with SQL SERVER Pin
CHill6017-Aug-22 7:00
mveCHill6017-Aug-22 7:00 
GeneralRe: Replacing back-end MS-ACCESS with SQL SERVER Pin
Nick Katditsik17-Aug-22 19:46
Nick Katditsik17-Aug-22 19:46 
QuestionHow would you... (synchronization between 2 databases) Pin
Joan M6-Aug-22 7:18
professionalJoan M6-Aug-22 7:18 
AnswerRe: How would you... (synchronization between 2 databases) Pin
Gerry Schmitz6-Aug-22 8:06
mveGerry Schmitz6-Aug-22 8:06 
GeneralRe: How would you... (synchronization between 2 databases) Pin
Joan M6-Aug-22 12:08
professionalJoan M6-Aug-22 12:08 
AnswerRe: How would you... (synchronization between 2 databases) Pin
Mycroft Holmes6-Aug-22 12:48
professionalMycroft Holmes6-Aug-22 12:48 
Questionsql query problem Pin
pitwi27-Jul-22 23:06
pitwi27-Jul-22 23:06 
AnswerRe: sql query problem Pin
Richard Deeming27-Jul-22 23:54
mveRichard Deeming27-Jul-22 23:54 
GeneralRe: sql query problem Pin
jsc4217-Aug-22 6:20
professionaljsc4217-Aug-22 6:20 
GeneralRe: sql query problem Pin
Richard Deeming17-Aug-22 6:26
mveRichard Deeming17-Aug-22 6:26 
GeneralRe: sql query problem Pin
jsc4217-Aug-22 22:40
professionaljsc4217-Aug-22 22:40 
Question.sql script in c# Pin
Member 1373522830-Jun-22 2:15
Member 1373522830-Jun-22 2:15 
AnswerRe: .sql script in c# Pin
Dave Kreskowiak30-Jun-22 3:59
mveDave Kreskowiak30-Jun-22 3:59 
QuestionPivot works, but spread column values not as expected Pin
#realJSOP19-Jun-22 1:58
mve#realJSOP19-Jun-22 1:58 
I have a table with the following schema:
SQL
DECLARE @images TABLE
(
    [Id]        BIGINT         NOT NULL,
    [UserId]    NVARCHAR(450)  NOT NULL,
    [VehID]     BIGINT         NOT NULL,
    [VehImage]  VARBINARY(MAX) NULL
);
There are no exactly 10 rows per user. Currently, all VehImage columns are null (intentionally).

Here is my sql query (@images is a table variable that I pre-populate with the desired records):

SQL
SELECT	UserId,VehID 
        ,[Image1],[Image2],[Image3],[Image4],[Image5]
        ,[Image6],[Image7],[Image8],[Image9],[Image10]
FROM	(
            SELECT	UserId 
                    ,VehID
                    ,VehImage
            FROM	@images
        ) AS SourceTable
PIVOT	(
            Count(VehImage)
            FOR VehImage IN ([Image1],[Image2],[Image3]
							,[Image4],[Image5],[Image6]
							,[Image7],[Image8],[Image9]
							,[Image10])
        ) AS PivotTable;
I have the pivot working, in that I get exactly one row back with the expected UserId, and VehId, and 10 image columns. My problem is that the Image columns all have the value 0 instead of the expected null.

What am I doing that would cause that?

EDIT ----------------------------------------

I changed the aggregate function from count to max, and all of the images are now showing null as expected. I don't know yet if that's the ultimate solution.

EDIT #2 -------------------------------------

Nope, I plugged a fake value into the first image record, and all of the image columns are still coming back as null...
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013


modified 19-Jun-22 8:13am.

AnswerRe: Pivot works, but spread column values not as expected Pin
Richard Deeming19-Jun-22 21:52
mveRichard Deeming19-Jun-22 21:52 

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.