December 4, 2009 at 6:03 am
Hi people
I wanted to join two tables with two colums that normally is doable, except that one is an ntext and the other is INT.
I used the the CAST method without any restult. All of this has to be done in a query cause i cant create new tables in the database.
select
admin.dbo.tblListItem.iItemID,
qa.dbo.tblevaluationanswers.ianswerID,
CAST(tblevaluationanswers.nvcanswer AS varchar(max)),
CAST(admin.dbo.tblListItem.iItemID AS varchar (max))
from qa.dbo.tblevaluationanswers inner join
admin.dbo.tblListItem on
admin.dbo.tblListItem.iItemID=nice_qa.dbo.tblevaluationanswers.nvcanswer
Is this possible without creating new querys?
:hehe:
December 4, 2009 at 7:47 am
Try this. You need to do the casts in the comparision.
select
tli.iItemID,
tva.ianswerID,
CAST(tva.nvcanswer AS varchar(max)),
CAST(tli.iItemID AS varchar (max))
from
qa.dbo.tblevaluationanswers tva
inner join admin.dbo.tblListItem tli
on (CAST(tli.iItemID AS varchar (max)) = CAST(tva.nvcanswer AS varchar(max)));
Also note that I am using table aliases. The use of 3 and 4 part names in the select clause is being depreciated.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply