Question : Microsoft SQL 2005

I have a simple query that is looking at two tables and sees which has the higher date, if a date exists it shows my results from my table.

II get the following error:

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'Select'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'Invoices'.
Code Snippet:
1:
2:
3:
4:
If (Select Max(InvoiceDate) from bill.dbo.Invoices) > Select Max(InvoicesRecdDate) from [Billing Automation Processes].dbo.billrunstatustable

Begin
Select Max(InvoiceDate) from bill.dbo.Invoices

Answer : Microsoft SQL 2005

try
If (Select Max(InvoiceDate) from bill.dbo.Invoices) > (Select Max(InvoicesRecdDate) from [Billing Automation Processes].dbo.billrunstatustable)
Begin
Select Max(InvoiceDate) from bill.dbo.Invoices
End
Random Solutions  
 
programming4us programming4us