Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi guys,Could you please help me. I have an an error message of this upon running this: "Incorrect syntax near the keyword 'distinct'.'OldIdNo' = distinct (C.Id1 + C.Id2 + C.Id3 + C.Id4)
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-01-28 : 05:23:44
If you tell me your business rule for this, I might be able to help.E 12°55'05.25"N 56°04'39.16"
sunil
Constraint Violating Yak Guru
282 Posts
Posted - 2008-01-28 : 05:24:43
you cannot use distinct (C.Id1 + C.Id2 + C.Id3 + C.Id4). You can useSelect distinct C.Id1 , C.Id2 , C.Id3 , C.Id4 from yourtable.EDIT: This is incorrect. correct replies are given in posts below.
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2008-01-28 : 05:28:52
quote:Originally posted by eem_2055 Hi guys,Could you please help me. I have an an error message of this upon running this: "Incorrect syntax near the keyword 'distinct'.'OldIdNo' = distinct (C.Id1 + C.Id2 + C.Id3 + C.Id4)
Can you post the full query?MadhivananFailing to plan is Planning to fail
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2008-01-28 : 05:29:23
Yes you can.
DECLARE @Sample TABLE (a VARCHAR(2), b VARCHAR(2), c VARCHAR(2), d VARCHAR(2))INSERT @SampleSELECT 'A', 'B', 'C', 'D' UNION ALLSELECT 'AB', 'CD', '', ''SELECT DISTINCT (a + b + c + d)FROM @Sample
E 12°55'05.25"N 56°04'39.16"
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2008-01-28 : 05:31:18
quote:Originally posted by sunil you cannot use distinct (C.Id1 + C.Id2 + C.Id3 + C.Id4). You can useSelect distinct C.Id1 , C.Id2 , C.Id3 , C.Id4 from yourtable.
select distinct (t.a+t.b) as sums from(select 34 as a , 16 as b union allselect 12 as a , 22 as b union allselect 34 as a , 16 as b )as tMadhivananFailing to plan is Planning to fail
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2008-01-28 : 05:33:54
MadhivananFailing to plan is Planning to fail
sunil
Constraint Violating Yak Guru
282 Posts
Posted - 2008-01-28 : 05:37:18
sorry eem_2055 for posting what i have come to know is incorrect.But, I read or heard it from some one.Thanks Peso and Madhi for the correction.