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 2005 Forums
 Transact-SQL (2005)
 Formating Numbers as Text

Author  Topic 

leslieb
Starting Member

23 Posts

Posted - 2008-07-23 : 21:16:24
I am only very new to SQL so am floundering. I am using SQL2005

I try to import data and one colum has numbers and also numbers and letters ie 1234, 1236, 123RT, etc. I am importing from excel and the 123RT does not import unless there is a number/letters in the first line to be imported.

Also when I run a query I get the number/letters 123RT but the straight numbers show as NULL.

Can anyone help a newbie?

dexter.knudson
Constraint Violating Yak Guru

260 Posts

Posted - 2008-07-23 : 23:38:33
yes this is frustrating. Is this a regular automated task or one-off? If it's one-off, try adding a blank space after the numbers in the columns in the first row where the column should be text.
Go to Top of Page

leslieb
Starting Member

23 Posts

Posted - 2008-07-24 : 01:42:50
It will be a regular process (daily) which we hope to automate in the future.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-24 : 02:57:45
or add single quote in front of the values

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

leslieb
Starting Member

23 Posts

Posted - 2008-07-24 : 19:54:17
Unfortunately it is not that easy as the data is coming from an excel spreadsheet and would be 1,000 line on a slow day. The only way I have got it to work so far is to Cut and paste from Excel into Access, Export from Access to Excel and then import into SQL.

I hope there is an easier way.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-25 : 02:59:31
How are you importing data?
Convert the data to varchar before importing

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

leslieb
Starting Member

23 Posts

Posted - 2008-08-14 : 20:55:00
I am using the 'Tasks' and then 'Import Data'.
How do I convert before importing?
If I use varchar and import direct from the Excel spreadsheet the codes with just numbers are fine but those with number and letters show as NULL. I have tried the same using text and nvarchar with the same result.
Go to Top of Page
   

- Advertisement -