Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

No data in one column of a view (NULL value instead

$
0
0
Hello,I have a table [DataXYZ].[dbo].[DataXYZ_GeoLoc_Input] with, as you can see, data for both "x" and "y" columns for year 2015:[img]http://www.cjoint.com/data/FKxqcfsonpU_XYZ-input.png[/img]I have a view [EntrepotXYZ].[dbo].[lv_DataXYZ_GeoLoc_Step1] created like this:[code="sql"]SELECT intras_annee, LEFT(siret, 9) AS intras_siren, siret + ident_int AS intras_cle_id, CAST(depcom_red + ISNULL(LTRIM(RTRIM(iris)) + REPLICATE('0', 4 - LEN(LTRIM(RTRIM(iris)))), REPLICATE('0', 4)) AS varchar(9)) AS intras_iris, CASE WHEN LEFT(depcom_red, 2) = '97' THEN LEFT(depcom_red, 3) ELSE LEFT(depcom_red, 2) END AS intras_dep, ident_org, siret, rs, cat_org, typeconst_red, nbpiece_red, construct_red, conv_red, numconv_red, CASE WHEN datconv_red IS NULL THEN NULL WHEN LTRIM(rtrim(datconv_red)) = '' THEN NULL ELSE RIGHT(datconv_red, 4) + '-' + SUBSTRING(datconv_red, 4, 2) + '-' + LEFT(datconv_red, 2) END AS datconv_red, rsexpro_red, siretexpro_red, finan_red, finanautre_red, cus_red, identges_red, ident_int, ident_rep, sru_expir_red, sru_alinea_red, reg, lib_reg, dep, lib_dep, epci, libepci, depcom_red, lib_depcom, codepostal_red, numvoie_red, indrep_red, typvoie_red, nomvoie_red, numappt_red, numboite_red, esc_red, couloir_red, etage_red, complident_red, entree_red, bat_red, immeu_red, complgeo_red, lieudit_red, zus_red, loyerprinc_red, loyeracc_red, contrib_red, CAST('' AS xml ).value('sql:column("loymoy") cast as xs:decimal ? ', 'decimal(7,3)') AS loymoy, loyermaxapl_red, loyermaxcus_red, locat_red, mode_red, bail_red, remlocdate_red, contreslog_red, duree_vacance, codsegpatrim_red, libsegpatrim_red, droit_red, patrimoine_red, origine_red, sortiepatrim_red, newlogt_red, oldlogt_red, dpedate_red, dpeenergie_red, dpeserre_red, surfhab_red, modesurf_red, surfmode_red, qualacq_red, miscommercial_red, prixvente_red, prodfin_red, mes_sanscumul, CAST('' AS xml ).value('sql:column("x") cast as xs:decimal ?', 'decimal(24,12)') AS x, CAST('' AS xml ).value('sql:column("y") cast as xs:decimal ?', 'decimal(24,12)') AS y, CAST('' AS xml ).value('sql:column("x_l2e") cast as xs:decimal ?', 'decimal(24,12)') AS x_l2e, CAST('' AS xml ).value('sql:column("y_l2e") cast as xs:decimal ?', 'decimal(24,12)') AS y_l2e, zus, zfu, iris, nqp, qp, ril, comazus, comazfu, comanqp, comaqpFROM DataXYZ.dbo.DataXYZ_GeoLoc_Input[/code]When I do a SELECT on this view for year 2015, "x" column has data but "y" column has "NULL" value:[img]http://www.cjoint.com/data/FKxqGpjxNzU_Y-2015-Null.png[/img]In fact, for year 2015, "y" column has a "NULL" value for each row:[img]http://www.cjoint.com/data/FKxqHQNgw0U_Y-not-null-0-lgn.png[/img]"x" an "y" value are handled the same way.Quite strange... :blink:Any idea of what could be the problem ?Thanks in advance.Regards,Steph.

Viewing all articles
Browse latest Browse all 3145

Trending Articles