RE: [SQLQueriesNoCode] Dynamically query to add columns to result table
- This example has a strange keyword WHEN which I can't find in the T-SQL
help. Actually it's listed in the "Reserved keywords" document but no
dedicated document article to talk about it. Am I missing something???
From: Razvan Socol [mailto:rsocol@...]
b) using the "Dynamic SQL" technique, like the following procedures:
- Actually the real scenario is more complicated than that, I only mentioned
the main meat of the query :)
There're a couple of other tables other than the WO table to query for more
outstanding quantities to fulfill for certain depts. On top of that, there's
also a request to eliminate any SO row that has all depts qty down to 0.
I can't show you the actual stored procedure query now because it's stashed
away on the server in an isolated network environment. It's a rather secure
environment i work there, and it's difficult to move things in and out. It's
a real suffocation.
Anyway, I've basically achieved what I wanted by manipulating at WF.NET and
ADO.NET level. The DataGrid's tablestyle and columnstyles were eliminated to
allow display of all columns, for what was previously a strong-typed
DataSet's DataTable - now schema-free. Once the query was retrieved I have
an automated code block to check through the table and note which DataRows
to remove (those with all 0).
With the above implementation, the only thing that needs to be changed is
the stored procedure. No recompilation of code. Not the most saavy and
elegant, but that'll have to do for now since I'm to concentrate on another
From: Max C. Parmenter [mailto:max.parmenter@...]
Sent: Wednesday, 28 April 2004 15:50
Subject: RE: [SQLQueriesNoCode] Dynamically query to add columns to result
Can you post the query for us to have a look at? Although your explanation
seems very thorough it always makes life easier if we can see what you're
- The keyword "WHEN" is part of the "CASE" structure. It is documented in Books Online, but if you prefer to read about it in MSDN here is the link:Razvan