Query with two types of INT and VARCHAR data

-2

I have two tables from which I select a field of each for the query and fill in the datagrid only that gives me error because the id is in int type and the other is a string of type varchar in which it has several ids registered.

It's sql server 2012 and the error

Thanks in advance and alanfcm I did not know about what would be the best option and the query is:

SELECT  dbo.Temporal_Price.Place_Id, dbo.Temporal_Price.Gas_Price, 
 dbo.Temporal_Price.Tipo, dbo.Temporal_Price.Update_Time
FROM  dbo.Cliente INNER JOIN
      dbo.Temporal_Price ON dbo.Cliente.Id_Com1 = dbo.Temporal_Price.Place_Id
    
asked by Aled 04.05.2018 в 20:16
source

1 answer

0

See if this solution works for you:

SELECT  
    dbo.Temporal_Price.Place_Id, 
    dbo.Temporal_Price.Gas_Price,
    dbo.Temporal_Price.Tipo, 
    dbo.Temporal_Price.Update_Time
 FROM  
  dbo.Cliente 
 INNER JOIN
  dbo.Temporal_Price ON 
  (
    dbo.Temporal_Price.Place_Id IN (
      SELECT t.c.value('.', 'VARCHAR(1000)')
        FROM (
          SELECT x = CAST('<t>' + 
             REPLACE(dbo.Cliente.Id_Com1 , ',', '</t><t>') + '</t>' AS XML)
        ) a
       CROSS APPLY x.nodes('/t') t(c)
    )
  );

Based on link

de yapa un fidel: link

    
answered by 07.05.2018 в 01:43