Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 incorrect syntax error near ')'

Author  Topic 

sunita
Starting Member

8 Posts

Posted - 2010-08-12 : 07:09:16
SELECT TOP (100) PERCENT b.bill_no, b.date, b.Amount, c.bill_no AS
Expr3, c.current_dat, em.date_adv_pay, em.adv_pay, ex.Date_of_expense,ex.Amount AS Expr5, ep.Date_of_Expense AS Expr6,
ep.Amount AS Expr7, en.bill_no AS Expr1,en.date AS Expr2, en.total, c.total AS Expr4
FROM bill_receive_entry b,
cus_pay_detail c,
emp_pay em,
expense_personnel ex,
expense_prod ep,
enlarge en
where b.date(+)=c.current_dat
and em.date_adv_pay=c.current_dat(+)
and ex.Date_of_expense = em.date_adv_pay(+)
and ep.Date_of_Expense = ex.Date_of_expense (+)
and en.date = ep.Date_of_Expense(+)
ORDER BY c.current_dat, c.bill_no, b.bill_no, em.date_adv_pay,ex.Date_of_expense, ep.Date_of_Expense, en.date

But the error is coming like, I am not able to detect the prob. Actually I am a fresher in sql. so plz do help it,s urgnt
Msg 102, Level 15, State 1, Line 10
Incorrect syntax near ‘)’.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-08-12 : 07:10:46
What is that?
b.date(+)
Are you using MS SQL Server?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

sunita
Starting Member

8 Posts

Posted - 2010-08-12 : 07:12:47
(+) is used for full outer join, I want to retrieve all data in current date
Go to Top of Page

sunita
Starting Member

8 Posts

Posted - 2010-08-12 : 07:14:03
yes for MS-SQL
Go to Top of Page

sunita
Starting Member

8 Posts

Posted - 2010-08-12 : 07:30:09
what happen????
Please reply soon I am waiting......
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-08-12 : 07:36:27
You know you shouldn't use these old kinds of joining?
It will only work in 2000 or before or 2005 with compatibility level 80...

And FULL OUTER JOIN was like this I think:
where a.Column *=* b.Column


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

kashyap_sql
Posting Yak Master

174 Posts

Posted - 2010-08-12 : 07:44:44
elaborate your need

With Regards
Kashyap M
Go to Top of Page

sunita
Starting Member

8 Posts

Posted - 2010-08-13 : 03:05:53
No!!!!!!!!!!

It's not working.
Again same error
Go to Top of Page

sunita
Starting Member

8 Posts

Posted - 2010-08-13 : 03:09:21
I am working in .net. I want to join all 6 tables using full outer join so that it will retrieve null values also. Condition to b used is: have to join in current date.
Go to Top of Page

sunita
Starting Member

8 Posts

Posted - 2010-08-13 : 03:28:01
SELECT TOP (100) PERCENT b.bill_no, b.date, b.Amount, c.bill_no AS Expr3, c.current_dat, em.date_adv_pay, em.adv_pay, ex.Date_of_expense,
ex.Amount AS Expr5, ep.Date_of_Expense AS Expr6, ep.Amount AS Expr7, en.bill_no AS Expr1, en.date AS Expr2, en.total, c.total AS Expr4
FROM dbo.bill_receive_entry AS b FULL OUTER JOIN
dbo.cus_pay_detail AS c ON b.date = c.current_dat FULL OUTER JOIN
dbo.emp_pay AS em ON c.current_dat = em.date_adv_pay FULL OUTER JOIN
dbo.expense_personnel AS ex ON em.date_adv_pay = ex.Date_of_expense FULL OUTER JOIN
dbo.expense_prod AS ep ON ex.Date_of_expense = ep.Date_of_Expense FULL OUTER JOIN
dbo.enlarge AS en ON ep.Date_of_Expense = en.date
ORDER BY c.current_dat, Expr3, b.bill_no, em.date_adv_pay, ex.Date_of_expense, Expr6, Expr2

This is working properly, bt in asp.net if i want to give condition then its nt working...

Can anybdy help me......
HELP!!!!!!!!!!!!!!!!!
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-08-13 : 03:29:57
"I want to join all 6 tables using full outer join"

Use FULL OUTER JOIN syntax then, not obsolete / deprecated (+) or (*) syntax
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-08-13 : 03:32:14
"bt in asp.net if i want to give condition then its nt working"

What condition?

What error message?
Go to Top of Page

remyo
Starting Member

6 Posts

Posted - 2010-08-13 : 03:56:12
As some people said .. use full outer joins.
Dunno which condition you wanna add but should look something like where table.field_contaning_date = selected_date

SELECT b.bill_no,
b.DATE,
b.amount,
c.bill_no AS expr3,
c.current_dat,
em.date_adv_pay,
em.adv_pay,
ex.date_of_expense,
ex.amount AS expr5,
ep.date_of_expense AS expr6,
ep.amount AS expr7,
en.bill_no AS expr1,
en.DATE AS expr2,
en.total,
c.total AS expr4
FROM bill_receive_entry b
FULL OUTER JOIN cus_pay_detail c
ON b.DATE = c.current_dat
FULL OUTER JOIN emp_pay em
ON em.date_adv_pay = c.current_dat
FULL OUTER JOIN expense_personnel ex
ON ex.date_of_expense = em.date_adv_pay
FULL OUTER JOIN expense_prod ep
ON ep.date_of_expense = ex.date_of_expense
FULL OUTER JOIN enlarge en
ON en.DATE = ep.date_of_expense
ORDER BY c.current_dat,
c.bill_no,
b.bill_no,
em.date_adv_pay,
ex.date_of_expense,
ep.date_of_expense,
en.DATE
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2010-08-13 : 04:26:47
how are you passing in this SQL statement to SQL Server?
Is your string holding it "long enough" to hold all the text? Is there any chance it is being truncated?

otherwise I agree with the "Full Outer" syntax comments above
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-08-13 : 04:49:14
I think O/P has already got to that point

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=148681#583774

but I'm a bit sceptical that joining all these Lookup tables with FULL OUTER JOINs is actually solving the O/P's problem. But we don't know what that is yet.
Go to Top of Page

sunita
Starting Member

8 Posts

Posted - 2010-08-14 : 02:03:17
But,if i want to give condition in.net for a particular date or month,then same error is coming,
the condition is like this:

Sqlcommand cmd=new Sqlcommand("Select .............. where b.date='"+combobox_date.selectedtext+"'",con);

why this is coming??????????
Go to Top of Page
   

- Advertisement -