﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2012 / SQL Server 2012 -  T-SQL  / Character '*' in float column / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 01:49:08 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>It does work.I did create a copy of the table with varchar columns instead of float and i insert the data in this table. An "instead of" trigger insert then the data in the proper table. That suits me cose it seems that they want to differentiate between when "*" is being written and when it s a blank. So i ll have a "text copy" of my measurements columns obviously.Thanks Sergiy! thanks to everyone for your advices, first step of a long run i think![sup][SELECT      [Code_Fournisseur]      ,[JOURJ]      ,[HEUREH]      ,[BANC]      ,[NUMPALE]      ,[Module_Status]      ,[Code_defaut]      ,TRY_CONVERT(float,[NeutralBefore_13])      ,TRY_CONVERT(float,[NeutralBefore_60])      ,TRY_CONVERT(float,[ST_4])      ,TRY_CONVERT(float,[ST_13])  FROM insertedEND[/sup]</description><pubDate>Fri, 15 Feb 2013 03:44:44 GMT</pubDate><dc:creator>ohpenot</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>Hi guys,Part number is a varchar column. Float columns are measurements.The solution i think is  what u said Sergyie. I m going to insert first temp table with varchar columns and then use the "TRY_CONVERT" function in "INSTEAD OF INSERT" trigger. I'll let u know if it works....!</description><pubDate>Fri, 15 Feb 2013 03:01:07 GMT</pubDate><dc:creator>ohpenot</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>WARNING!  Storing PART NUMBERS as FLOAT will eventually and absolutely screw you to the deck without warning.[code="sql"]DECLARE @PartNumber FLOAT; SELECT @PartNumber = 1234567890123456; SELECT @PartNumber AS ScrewedALittle; SELECT @PartNumber = 12345678901234567; SELECT @PartNumber AS ScrewedALot;[/code]If you store the part "number" as a VARCHAR (as you would other "numbers" that aren't really numbers such as telephone numbers, zip codes, SSNs, etc) , then you can have your "*" cake and eat it, too! :-D</description><pubDate>Thu, 14 Feb 2013 22:49:03 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>Or you can create a view on top of the table with those FLOAT columns converted to VARCHAR and set up an INSTEAD OF INSERT, UPDATE trigger on it - same code as posted above.</description><pubDate>Thu, 14 Feb 2013 17:10:55 GMT</pubDate><dc:creator>Sergiy</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>Bottom line, you can't put a * into a float column, it's not a float. It you want to badly mess thing up, you could convert the column to a varchar then spend huge time and effort fixing bad data, correcting 'broken' calculations and making massive amounts of work for yourself. If the data is numeric then the column should not be a varchar.You can convert nulls to * in the queries that retrieve from the table.</description><pubDate>Thu, 14 Feb 2013 06:02:58 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>Hi Sergiy,Indeed, i tried to run today and it s not working.USE [test1]GO   BULK INSERT [dbo].[TABLETEST1]   FROM 'C:\Users\HPENOT\Documents\data_xls\ligneEOLT2etoile.txt'   WITH     (        FIELDTERMINATOR =';',        ROWTERMINATOR = '',		FIRE_TRIGGERS      )GOMsg 4864, Niveau 16, État 1, Ligne 2Erreur de conversion des données de chargement en masse (incompatibilité de type ou caractère non valide pour la page de codes spécifiée) pour la ligne 1, colonne 12 (ST_13).(0 ligne(s) affectée(s))USE [test1]GO/****** Object:  Trigger [dbo].[nullifetoile]    Script Date: 14/02/2013 13:06:44 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER TRIGGER [dbo].[nullifetoile] ON  [dbo].[TABLETEST1]INSTEAD OF INSERTAS BEGININSERT [dbo].[TABLETEST1]           ([NUMCAM]           ,[Code_Fournisseur]           ,[JOURJ]           ,[HEUREH]           ,[BANC]           ,[NUMPALE]           ,[Module_Status]           ,[Code_defaut]           ,[NeutralBefore_13]           ,[NeutralBefore_60]           ,[ST_4]           ,[ST_13])  SELECT           [NUMCAM]           ,[Code_Fournisseur]           ,[JOURJ]           ,[HEUREH]           ,[BANC]           ,[NUMPALE]           ,[Module_Status]           ,[Code_defaut]           ,CONVERT(float,NULLIF([NeutralBefore_13],'*'))           ,CONVERT(float,NULLIF([NeutralBefore_60],'*'))           ,CONVERT(float,NULLIF([ST_4],'*'))           ,CONVERT(float,NULLIF([ST_13],'*'))	         FROM INSERTEDEND</description><pubDate>Thu, 14 Feb 2013 05:07:18 GMT</pubDate><dc:creator>ohpenot</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>[quote][b]ohpenot (2/13/2013)[/b][hr]That is exactly what i was looking for. [/quote]Not sure about that.Did you try to run it?It won't work if those columns in dbo.Tablebase are of FLOAT data type.Table INSERTED will have the same column definitions as dbo.Tablebase, so an attempt to place '*' into a FLOAT column will result in run time error.And if the columns are of a one of the CHAR data types you face the issues coming from implicit conversions from FLOAT to VARCHAR.You may get some nasty surprises on this way.</description><pubDate>Wed, 13 Feb 2013 17:32:53 GMT</pubDate><dc:creator>Sergiy</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>That is exactly what i was looking for. thanks a lot Lowell!PS : Sorry for the error in my post, I actually did an INSTEAD OF trigger.</description><pubDate>Wed, 13 Feb 2013 07:50:12 GMT</pubDate><dc:creator>ohpenot</dc:creator></item><item><title>RE: Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>not sure about the trigger being what you want to do or not...it should be an instead of trigger and not a FOR/AFTER trigger, i thinka float cannot have an asterisk in it, so the data must be a char/varchar data type.to put it in a float column, you should explcitly convert it to a float datatype i think:[code]SELECT[N° CAM],[C# fourn],[date],[heure],[banc],[N° Pale#],[Module_Status],[Code défaut],CONVERT(float,NULLIF([NeutralBefore_13],'*')),CONVERT(float,NULLIF([NeutralBefore_60],'*')),CONVERT(float,NULLIF([S_T4],'*')),CONVERT(float,NULLIF([S13_IminPPV1],'*'))[/code]</description><pubDate>Wed, 13 Feb 2013 07:40:39 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Character '*' in float column</title><link>http://www.sqlservercentral.com/Forums/Topic1419481-3077-1.aspx</link><description>Hi everybody,I m an intern in charge of creating an sql server database for production data. We got basically parts numbers and measurements which are float columns. To avoid having any doubt considering blanks (to differentiate between bugs and normal NULLS as far as i understood), the engineering team here decided to put "*" instead of nothing. (Data is csv files).[size="7"] [b]I need to consider this '*' as NULL in a column which has float type.[/b][/size]I tried a trigger "instead of insert" and NULLIF on '*' character but obviously the two parameters of the NULLIF need to be of the same type.[b]I've been told the easiest thing to do would be to modify the data before insert. Is it true[/b]Here is a reduced part of the code :CREATE TRIGGER etoilenulle4 ON  dbo.TablebaseAFTER INSERTAS BEGININSERT [dbo].[Tablebase]           ([N° CAM]           ,[C# fourn]           ,[date]           ,[heure]           ,[banc]           ,[N° Pale#]           ,[Module_Status]           ,[Code défaut]           ,[NeutralBefore_13]           ,[NeutralBefore_60]           ,[S_T4]           ,[S13_IminPPV1])  SELECT            [N° CAM]           ,[C# fourn]           ,[date]           ,[heure]           ,[banc]           ,[N° Pale#]		   ,[Module_Status]           ,[Code défaut]           ,NULLIF([NeutralBefore_13],'*')           ,NULLIF([NeutralBefore_60],'*')           ,NULLIF([S_T4],'*')           ,NULLIF([S13_IminPPV1],'*')FROM INSERTEDEND</description><pubDate>Wed, 13 Feb 2013 06:50:59 GMT</pubDate><dc:creator>ohpenot</dc:creator></item></channel></rss>