Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 record replacement

Author  Topic 

goligol
Posting Yak Master

128 Posts

Posted - 2011-09-09 : 14:21:12
Hi

I am importing an excel sheet in SQL using task and import.

although the format of the column in excel is text, still has difficulties importing "0" and numbers like "09" to SQL and import it as NULL in SQL. I have also difficulty to edit it manually since it goes to error. I was wondering if I can use some commands to replace those nulls with actual number:

SELECT [Division]
,[Fips_st]
FROM [Transportation].[dev].[Dev2St_Keys]

************ for example "replace Divison = 8 and Fips_st= Null with Divison=8 and Fips_s= 09"

Thank you

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-09 : 14:26:15
[code]SELECT [Division]
,case when Divison=8 and Fips_st is Null then '09' else [Fips_st] end
FROM [Transportation].[dev].[Dev2St_Keys]
[/code]

i assume Fips_st is of type varchar else you've to do a cast

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

Go to Top of Page

goligol
Posting Yak Master

128 Posts

Posted - 2011-09-09 : 14:59:16
it will not help my case, I do not want to create a new columen:
my table is as below:

8 NULL
8 NULL
8 35
8 30
8 49
8 32
8 56
9 NULL
9 NULL

I want to replace Nulls with different numbers.
example
8 09
8 01
8 35
8 30
8 49
8 32
8 56
9 04
9 02
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-10 : 00:58:30
ok thats fine. but where will you get numbers like 09,01,04 etc from? are they stored in another column or maybe in another table?

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

Go to Top of Page
   

- Advertisement -