Click here to Skip to main content
15,904,288 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Statment Pin
John-ph28-Sep-07 20:43
John-ph28-Sep-07 20:43 
QuestionObject Persistence Pin
gus_br28-Sep-07 9:18
gus_br28-Sep-07 9:18 
AnswerRe: Object Persistence Pin
Colin Angus Mackay28-Sep-07 9:44
Colin Angus Mackay28-Sep-07 9:44 
GeneralRe: Object Persistence Pin
gus_br28-Sep-07 9:52
gus_br28-Sep-07 9:52 
GeneralRe: Object Persistence Pin
Colin Angus Mackay28-Sep-07 10:03
Colin Angus Mackay28-Sep-07 10:03 
QuestionCommon Dialog Object Reference... Pin
new_phoenix28-Sep-07 9:07
new_phoenix28-Sep-07 9:07 
QuestionHaving trouble with a TableDef object... Pin
new_phoenix28-Sep-07 6:56
new_phoenix28-Sep-07 6:56 
Questioncolumn as stored procedure parameter? Pin
Ed Hill _5_28-Sep-07 6:06
Ed Hill _5_28-Sep-07 6:06 
I have a storedProcedure i need to modify so it can sort by one of two columns, i need to allow the program calling the stored procedure to choose which one it wants the data sorted by, currently there are serveral if statments deciding exactly which select statment i will run, i need all of them to have the order by on the end as a variable passed into the stored procedure, is there any way to do this?

my last try:
if @Filter = 'All' and @DateFrom is Null and @MatterRef = ''<br />
BEGIN<br />
select * <br />
from undertakings <br />
order by <br />
	case <br />
		when @sortBy = 'matterRef' then undertakings.MatterRef<br />
		when @sortBy = 'Date' then undertakings.DateTaken<br />
	end<br />
END<br />
if @filter = 'Active' and @DateFrom is Null and @MatterRef = ''<br />
BEGIN<br />
select * <br />
from undertakings <br />
where Discharged = 0 <br />
order by <br />
	case <br />
		when @sortBy = 'matterRef' then undertakings.MatterRef<br />
		when @sortBy = 'Date' then undertakings.DateTaken<br />
	end<br />
END<br />
if @Filter = 'Discharged' and @DateFrom is Null and @MatterRef = ''<br />
BEGIN<br />
select * <br />
from undertakings <br />
where Discharged = 1 <br />
order by <br />
	case <br />
		when @sortBy = 'matterRef' then undertakings.MatterRef<br />
		when @sortBy = 'Date' then undertakings.DateTaken<br />
	end<br />
END

the procedure is a little more complex, with several other condtions but you should be able to get the idea.
Any help or pointers would be appreciated
AnswerRe: column as stored procedure parameter? Pin
John-ph28-Sep-07 10:47
John-ph28-Sep-07 10:47 
GeneralRe: column as stored procedure parameter? Pin
Ed Hill _5_1-Oct-07 0:26
Ed Hill _5_1-Oct-07 0:26 
GeneralRe: column as stored procedure parameter? Pin
John-ph2-Oct-07 19:47
John-ph2-Oct-07 19:47 
QuestionPASSWORD RETRIEVAL Pin
LyndonJohn28-Sep-07 3:34
LyndonJohn28-Sep-07 3:34 
AnswerRe: PASSWORD RETRIEVAL Pin
Pete O'Hanlon28-Sep-07 4:01
mvePete O'Hanlon28-Sep-07 4:01 
AnswerRe: PASSWORD RETRIEVAL Pin
Colin Angus Mackay28-Sep-07 4:24
Colin Angus Mackay28-Sep-07 4:24 
AnswerRe: PASSWORD RETRIEVAL Pin
Paul Conrad2-Oct-07 10:30
professionalPaul Conrad2-Oct-07 10:30 
QuestionSQL to get DataTypes Pin
RichardBerry28-Sep-07 3:21
RichardBerry28-Sep-07 3:21 
AnswerRe: SQL to get DataTypes Pin
Colin Angus Mackay28-Sep-07 3:31
Colin Angus Mackay28-Sep-07 3:31 
GeneralRe: SQL to get DataTypes Pin
RichardBerry30-Sep-07 21:16
RichardBerry30-Sep-07 21:16 
GeneralRe: SQL to get DataTypes Pin
Colin Angus Mackay1-Oct-07 6:32
Colin Angus Mackay1-Oct-07 6:32 
GeneralRe: SQL to get DataTypes Pin
RichardBerry2-Oct-07 1:20
RichardBerry2-Oct-07 1:20 
AnswerRe: SQL to get DataTypes Pin
PIEBALDconsult28-Sep-07 5:42
mvePIEBALDconsult28-Sep-07 5:42 
AnswerRe: SQL to get DataTypes Pin
John-ph28-Sep-07 20:22
John-ph28-Sep-07 20:22 
GeneralRe: SQL to get DataTypes Pin
RichardBerry30-Sep-07 21:36
RichardBerry30-Sep-07 21:36 
GeneralRe: SQL to get DataTypes Pin
John-ph30-Sep-07 22:51
John-ph30-Sep-07 22:51 
GeneralRe: SQL to get DataTypes Pin
RichardBerry30-Sep-07 23:03
RichardBerry30-Sep-07 23:03 

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.