SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 error in query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Gekko
Yak Posting Veteran

Slovenia
63 Posts

Posted - 11/20/2012 :  07:38:14  Show Profile  Reply with Quote
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 c
LEFT OUTER JOIN TabCisZam VCisOrgOdpOs ON c.OdpOs=VCisOrgOdpOs.ID

query 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 predajca

FROM tabcisorg c
LEFT OUTER JOIN TabCisZam VCisOrgOdpOs ON c.OdpOs=VCisOrgOdpOs.ID

big thanks

Edited by - Gekko on 11/20/2012 07:55:05

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/20/2012 :  07:41:48  Show Profile  Reply with Quote
Missing left bracket - see in red below
SELECT 
VCisOrgOdpOs.stredisko,c.cisloorg,c.ico,c.nazev,
predajca = CAST( STUFF((SELECT 
DISTINCT ', '+convert(varchar(10),CONVERT(int, e.Stredisko),','+e.prijmeni)
....
Go to Top of Page

Gekko
Yak Posting Veteran

Slovenia
63 Posts

Posted - 11/20/2012 :  07:50:33  Show Profile  Reply with Quote
not

error is somewhere in syntax

but thanks
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/20/2012 :  08:01:48  Show Profile  Reply with Quote
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 this
DISTINCT ', '+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.
Go to Top of Page

Gekko
Yak Posting Veteran

Slovenia
63 Posts

Posted - 11/20/2012 :  09:11:30  Show Profile  Reply with Quote
not

Forget broader problem is somewhere in the syntax
I must solved myself

thanks for trying

I closed topic
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000