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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Initializing Null Values

Author  Topic 

pizzojm
Starting Member

20 Posts

Posted - 2003-02-04 : 15:49:56
Hello All. I have a table which has many rows, all of which are labeled as NOT NULL. Some of these include address fields and currency fields, such as Addr1 Varchar and Sales Currency. My problem is I am trying to load a file which has null values for some of these rows, and this is obviously not allowed. I am NOT able to change the database design to allow nulls (which would be the best answer), and I did not want to go through tens of thousands of records to add spaces and zeros for when there are null values in the file. Is there any way to initialize or a work around related to the SQL here?... Or any other slick way someone has worked around a problem like this? Any help and ideas would be greatly appreciated! Thank You.

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2003-02-04 : 15:52:35
If you cant change the base table design to either allow nulls or supply a default value you could import the data into a staging table. From there insert...select all rows into the base table and any row that may have a null use the isnull() function to supply a default value.

hth,
Justin

Expect 0x80040106
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-02-04 : 16:08:10
You can put an instead of trigger on the table to suply the values.

How are you laoding the file?

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

pizzojm
Starting Member

20 Posts

Posted - 2003-02-04 : 16:11:45
Using standard sql load from file.txt command

[quote]
You can put an instead of trigger on the table to suply the values.

How are you laoding the file?



Go to Top of Page
   

- Advertisement -