chris123321
IS-IT--Management
In an excel sheet, there is a zip code column. The data type of that column in excel is General. The zip code can have letters as it contains international zip codes.
After importing the data from excel into a sql server table, the zip codes that don't have any letters have a value of NULL. The zip code data type in sql server is nvarchar(15). For example, a zip code in Excel that is 10001A will import properly into the table, but a zip code as 7015 will import as NULL into the table.
What I've tried:
1) Create a new column as text in Excel, copy the values from the original column, and then import the data into the sql table. Still got NULL values for 7015.
What has worked is adding a single quote to 7015 in Excel and then importing into sql. This works, but the problem is that I'm not sure how to programatically do this for all the rows. Any suggestion?
Also adding zzzz to 7015 and then importing into sql works as well. But how can I do this programatically?
Any other suggestions?
After importing the data from excel into a sql server table, the zip codes that don't have any letters have a value of NULL. The zip code data type in sql server is nvarchar(15). For example, a zip code in Excel that is 10001A will import properly into the table, but a zip code as 7015 will import as NULL into the table.
What I've tried:
1) Create a new column as text in Excel, copy the values from the original column, and then import the data into the sql table. Still got NULL values for 7015.
What has worked is adding a single quote to 7015 in Excel and then importing into sql. This works, but the problem is that I'm not sure how to programatically do this for all the rows. Any suggestion?
Also adding zzzz to 7015 and then importing into sql works as well. But how can I do this programatically?
Any other suggestions?