Pasting Null values in SQL
Ok, I'm trying to figure out how to paste a bunch of records from excel to an SQL table. Some fields will contain no data. When I paste into the table, it makes the fields that have no data Null. I set it up so any new records entered in the table and have fields that contain no data will be an empty string. i put a value of "" instead of Null. But when I do paste records it keeps the fields with no data as Null. Is there a way to make anything pasted, imported, or appended not created NULL values for fields that contain no data, either in the table design or within the excel spreadsheet, etc. Thanks in advance for any information.
Re: Pasting Null values in SQL
What is wrong with having NULL values in those fields? I use NULLs all the time.
Re: Pasting Null values in SQL
Well I'm comparing data lets say between two tables. One column contains fields with data and fields with no data. I try to run a query to match records from 2 different tables. It shows all records that match that have data in every field but excludes any records that match but do have fields that have null values in them. But if I go through and change any no data fields that are null to an empty string using ""...all records that match that has both empty fields and do contain values..show up which i do want.
Re: Pasting Null values in SQL
An OUTER JOIN as opposed to an INNER JOIN should bring back all records regardless of whether they are NULL or not.
Re: Pasting Null values in SQL
Quote:
Originally Posted by SeanK
An OUTER JOIN as opposed to an INNER JOIN should bring back all records regardless of whether they are NULL or not.
I'll give it a try ...thank you ;)
Re: Pasting Null values in SQL
You could also use a function in the SQL to convert Null values to empty strings, whilst leaving non-null values as they are.
I presume by "SQL table" you actually mean that you are using SQL Server (as opposed to Access/Oracle/MySQL/... which also use the language SQL), in which case you can do it using the IsNull function, eg:
Code:
...
WHERE IsNull(Table1.FieldA, '') = IsNull(Table2.FieldA, '')
...