Author |
Topic |
Gekko
Yak Posting Veteran
63 Posts |
Posted - 2012-11-20 : 07:38:14
|
Good day everybody.Next query has error, Can we help me pleas?SELECT VCisOrgOdpOs.stredisko,c.cisloorg,c.ico,c.nazev,predajca = CAST STUFF((SELECT DISTINCT ', '+convert(varchar(10),CONVERT(int, e.Stredisko),','+e.prijmeni) FROM hvw_predajcovia r INNER JOIN tabciszam e ON e.cislo=r.cislozam WHERE x.cisloorg=c.cisloorg FOR XML PATH('')),1,1,'') as nvarchar(25))FROM tabcisorg cLEFT OUTER JOIN TabCisZam VCisOrgOdpOs ON c.OdpOs=VCisOrgOdpOs.IDquery comes from this that is completely correct.I want convert +e.stredisko on "+convert(varchar(10),CONVERT(int, e.Stredisko)"from this correct query:SELECT VCisOrgOdpOs.stredisko,c.cisloorg,c.ico,c.nazev,STUFF((SELECT DISTINCT ','+e.stredisko,','+e.prijmeni FROM hvw_predajcovia r INNER JOIN tabciszam e ON e.cislo=r.cislozam WHERE r.cisloorg=c.cisloorg FOR XML PATH('')),1,1,'') as predajcaFROM tabcisorg cLEFT OUTER JOIN TabCisZam VCisOrgOdpOs ON c.OdpOs=VCisOrgOdpOs.IDbig thanks |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-20 : 07:41:48
|
Missing left bracket - see in red belowSELECT VCisOrgOdpOs.stredisko,c.cisloorg,c.ico,c.nazev,predajca = CAST( STUFF((SELECT DISTINCT ', '+convert(varchar(10),CONVERT(int, e.Stredisko),','+e.prijmeni).... |
|
|
Gekko
Yak Posting Veteran
63 Posts |
Posted - 2012-11-20 : 07:50:33
|
noterror is somewhere in syntaxbut thanks |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-20 : 08:01:48
|
You do need the left bracket that I highlighted in my previous post. In addition, it seems like there is an error here:DISTINCT ', '+convert(varchar(10),CONVERT(int, e.Stredisko),','+e.prijmeni) It perhaps should be something like thisDISTINCT ', '+convert(varchar(10),CONVERT(int, e.Stredisko))+','+e.prijmeni But I am only guessing - what are you trying to get using the two convert functions? Regardless, if e.Stredisko is not something that can be converted to an integer, the query would fail. |
|
|
Gekko
Yak Posting Veteran
63 Posts |
Posted - 2012-11-20 : 09:11:30
|
notForget broader problem is somewhere in the syntaxI must solved myselfthanks for tryingI closed topic |
|
|
|
|
|