Click here to Skip to main content
15,917,005 members
Home / Discussions / Database
   

Database

 
AnswerRe: In sql service reports Pin
Paddy Boyd14-Nov-08 5:44
Paddy Boyd14-Nov-08 5:44 
GeneralRe: In sql service reports Pin
member2714-Nov-08 20:18
member2714-Nov-08 20:18 
QuestionStored Procedure Error Pin
Syed Shahid Hussain14-Nov-08 1:40
Syed Shahid Hussain14-Nov-08 1:40 
AnswerRe: Stored Procedure Error PinPopular
neilarnold14-Nov-08 2:00
neilarnold14-Nov-08 2:00 
GeneralRe: Stored Procedure Error Pin
Syed Shahid Hussain14-Nov-08 2:34
Syed Shahid Hussain14-Nov-08 2:34 
GeneralRe: Stored Procedure Error Pin
Syed Shahid Hussain14-Nov-08 2:41
Syed Shahid Hussain14-Nov-08 2:41 
GeneralRe: Stored Procedure Error Pin
Jeremy Falcon14-Nov-08 6:21
professionalJeremy Falcon14-Nov-08 6:21 
QuestionProblem with SQL Where - using IF or CASE Pin
But_Im_a_Lady13-Nov-08 23:11
But_Im_a_Lady13-Nov-08 23:11 
Hi All,

After searching the web for a solution I just seem to be more confused - If someone could throw some light on this I would really appreciate it - as my sql isn't brill as you will see..

I have a sql SP which accepts 2 params:

@SalesOrderID int = 0,
@AllocationEndDate datetime

The select statement contain various joins from orders & allocations tables.

Its the main where clause that I am having issues with
- If I pass a SalesOrderID into this SP I want the where to match this ID along with some date checking & a trans type. If I dont pass a SalesOrderID I want the where to just match on the date checking & a trans type.

See below the code which I have & that doesnt work:-

IF @SalesOrderID = 0
Begin
	Where 
	(M.DateTransactionDue >= '01/01/1900' AND M.DateTransactionDue <= @AllocationEndDate) AND M.TransactionTypeID = 1
END
ELSE
Begin
	Where
	(M.SalesOrderID = @SalesOrderID) AND (M.DateTransactionDue >= '01/01/1900') AND (M.DateTransactionDue <= @AllocationEndDate) AND 
	(M.TransactionTypeID = 1)
END


I did try a Case statement I couldn't get that to work either:-

--WHERE     

--(case @SalesOrderID

--when 0 	  M.DateTransactionDue >= '01/01/1900' AND M.DateTransactionDue <= @AllocationEndDate AND 
--          M.TransactionTypeID = 1
          
--when > 0  (M.SalesOrderID = @SalesOrderID) AND (M.DateTransactionDue >= '01/01/1900') AND (M.DateTransactionDue <= @AllocationEndDate) AND 
--          (M.TransactionTypeID = 1)
          
--          else -1
          
--          end) 


Many thanks
Janet

Lady Programmers are a rare breed!

AnswerRe: Problem with SQL Where - using IF or CASE Pin
Ben Fair14-Nov-08 3:14
Ben Fair14-Nov-08 3:14 
GeneralRe: Problem with SQL Where - using IF or CASE Pin
But_Im_a_Lady14-Nov-08 3:53
But_Im_a_Lady14-Nov-08 3:53 
QuestionProblem with synonyms in SQL Server 2005 Pin
boabab13-Nov-08 20:59
boabab13-Nov-08 20:59 
AnswerRe: Problem with synonyms in SQL Server 2005 Pin
Wendelius14-Nov-08 7:37
mentorWendelius14-Nov-08 7:37 
QuestionHow to get the schema of results from a stored procedure Pin
gantww13-Nov-08 11:00
gantww13-Nov-08 11:00 
AnswerRe: How to get the schema of results from a stored procedure Pin
Mycroft Holmes13-Nov-08 15:46
professionalMycroft Holmes13-Nov-08 15:46 
GeneralRe: How to get the schema of results from a stored procedure Pin
gantww13-Nov-08 17:17
gantww13-Nov-08 17:17 
QuestionSQL Express 2005 Database Read-Only Problem Pin
Ahmad Safwat13-Nov-08 3:37
Ahmad Safwat13-Nov-08 3:37 
AnswerRe: SQL Express 2005 Database Read-Only Problem Pin
Wendelius13-Nov-08 4:52
mentorWendelius13-Nov-08 4:52 
GeneralRe: SQL Express 2005 Database Read-Only Problem Pin
Ahmad Safwat13-Nov-08 5:37
Ahmad Safwat13-Nov-08 5:37 
GeneralRe: SQL Express 2005 Database Read-Only Problem Pin
Wendelius13-Nov-08 6:53
mentorWendelius13-Nov-08 6:53 
GeneralRe: SQL Express 2005 Database Read-Only Problem Pin
Ahmad Safwat15-Nov-08 21:11
Ahmad Safwat15-Nov-08 21:11 
GeneralRe: SQL Express 2005 Database Read-Only Problem Pin
Wendelius15-Nov-08 21:38
mentorWendelius15-Nov-08 21:38 
GeneralRe: SQL Express 2005 Database Read-Only Problem Pin
Ahmad Safwat15-Nov-08 23:50
Ahmad Safwat15-Nov-08 23:50 
GeneralRe: SQL Express 2005 Database Read-Only Problem Pin
Wendelius15-Nov-08 23:57
mentorWendelius15-Nov-08 23:57 
AnswerRe: SQL Express 2005 Database Read-Only Problem Pin
Paul Conrad13-Nov-08 6:39
professionalPaul Conrad13-Nov-08 6:39 
Questioninsert into and varbinary Pin
swjam13-Nov-08 2:18
swjam13-Nov-08 2:18 

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.