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 2008 Forums
 Transact-SQL (2008)
 Implicit conversion error
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dharm280
Starting Member

India
1 Posts

Posted - 06/08/2012 :  04:44:25  Show Profile  Reply with Quote
Hi,
I am working on a dynamic query for updated data check and its work fine for 145 tables but in for some table erros occured like
"Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict."

When i add keyword "COLLATE DATABASE_DEFAULT" with Varchar datatype column name its run, but problem is that how can i add this dynamically in query,

Query is like this :-
select Count(*) from (

SELECT MIN(PlazaDatabase) as TableName,a.CplazaId,a.[ContactMeansID],a.[ContactMeansType],a.[Value],a.[Comments],a.[Active],a.[ClientID]

FROM
(
select 'PlazaDatabase'as PlazaDatabase, 2 'CPlazaID',a.[ContactMeansID],a.[ContactMeansType],a.[Value],a.[Comments],a.[Active],a.[ClientID] from [192.168.1.10].[TollSongir].[dbo].[ContactMeans] a
union all
select 'CentralDatabase'as CentralDatabase, a.CplazaId,a.[ContactMeansID],a.[ContactMeansType],a.[Value],a.[Comments],a.[Active],a.[ClientID] from [DPTLNEWTEST].[dbo].[ContactMeans] a where a.cPlazaid=2
)a
group by a.CPlazaId,a.[ContactMeansID],a.[ContactMeansType],a.[Value],a.[Comments],a.[Active],a.[ClientID]
HAVING COUNT(*) = 1)a where a.TableName='PlazaDatabase'


CAn any one give me permanent solution

its urgent for me

Thnaks & Regards
Dharmendra Kuamr




Dharmendra Kumar

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 06/08/2012 :  05:58:48  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Why not add that to all varchar column compares.
You could also check the collation when building the dynamic sql and add the collate if necessary,

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47140 Posts

Posted - 06/08/2012 :  12:11:56  Show Profile  Reply with Quote
you can add COLLATE part inside dynamic string where you're doing varchar comparisons

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.28 seconds. Powered By: Snitz Forums 2000