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
 Converting nvchar to float

Author  Topic 

goligol
Posting Yak Master

128 Posts

Posted - 2011-11-29 : 12:32:12
I want to union two tables. the type of one of the Coulom in one of the tables in float and in the other one is nvarchar.

I want to make them both float:

SELECT cast([port] as float ) port
,[port_name]

FROM [trade].[dev].[scheduleD]

union

SELECT [port]
,[Name] port_name

FROM [trade].[ft].[ScheduleD]

but it gives an error:

Error converting data type nvarchar to float.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-29 : 12:39:31
first check if you've any non-numeric data also existing in nvarchar column.

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

Go to Top of Page

goligol
Posting Yak Master

128 Posts

Posted - 2011-11-29 : 12:45:38
is there any command to check that!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-29 : 12:52:02
[code]select count(*) from
FROM [trade].[dev].[scheduleD]
where [port] LIKE '%[^0-9]%'
[/code]

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

Go to Top of Page

goligol
Posting Yak Master

128 Posts

Posted - 2011-11-29 : 13:28:26
Thank you so much
Go to Top of Page
   

- Advertisement -