Páginas

terça-feira, 26 de abril de 2011

MSSQL - Collation ERRO entre Database ou Table

Bem Pessoal,

Segue hoje com a reativação do blog, agora sobre novo endereço (tirei o site do ar estava difícil manter).

O Erro de hoje é sobre Selects multiplos que dão conflito devido ao Collation.

select
  a.ambiente
  d.cnpj
from
  EP.dbo.e_ambientes a,
  EP.dbo.e_restaurantes b,
  EP.dbo.e_casas c,
  FW.dbo.estabulo d
where
  b.restaurantecod = b.codrestaurante and
  d.cnpj = c.id;

/*
Cannot resolve the collation conflict between "SQL_Latin1_General_CP850_CI_AI" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation
*/

A solução:

Primeiramente, pensei em alterar o Collate da base mas não fui muito bem nisso então eu vi algo sobre selects de multiplas linguagens em um site árabe.

select
  a.ambiente
  d.cnpj
from
  EP.dbo.e_ambientes a,
  EP.dbo.e_restaurantes b,
  EP.dbo.e_casas c,
  FW.dbo.estabulo d
where
  b.restaurantecod = b.codrestaurante and
  d.cnpj = c.id collate SQL_Latin1_General_CP1_CI_AS;

/*
a.ambiente | d. cnpj
Funcinando | 052365245000106
*/

Nenhum comentário:

Postar um comentário