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
 Cross Apply Function - Urgent Help

Author  Topic 

satheesh
Posting Yak Master

152 Posts

Posted - 2011-01-28 : 05:12:41
Hi All,

I tried to execute below query .I got an error -Conversation failed when converting the varchar vale 'Mr.Aa.Aa to data type int'.

If i remove this [''+',' +.age+ ''] from select, its working fine.But i need to include the age field.How to amend this query.Any help would be highly appreciated.

Age field datatye-int
all other field datatype varchar

select .............
...............................................................
from table1

cross apply (

select cst.title +''+ '.'+cst.fname +''+ ' '+cst.lname + ''+',' +.age+ ''+' ' as [text()]


from cstwhere temp.Id = cst.Id

order by cst.FName

for xml path ('')

)cst(customerss)

edit: moved to correct forum

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-01-28 : 05:15:01
... +convert(varchar(3),age)+ ...


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

satheesh
Posting Yak Master

152 Posts

Posted - 2011-01-28 : 05:25:28
Thanks webferd,

I changed thats as

cross apply (
select cst.title +''+ '.'+cst.fname +''+ ' '+cst.lname + ''+',' +convert( varchar (3),cst.age+ ''+' ' as [text()]

It returned an error msg -
Incorrect syntax near the keyword 'as'.

Thank in advance..
Go to Top of Page

satheesh
Posting Yak Master

152 Posts

Posted - 2011-01-28 : 05:33:20
Many Thanks i sorted out.
Go to Top of Page
   

- Advertisement -