Convert nvarchar to bigint in Sql server 2008 Convert nvarchar to bigint in Sql server 2008 sql sql

Convert nvarchar to bigint in Sql server 2008


You could try to use ISNUMERIC to determine those rows that are indeed numeric:

UPDATE dbo.YourTableSET BigIntColumn = CAST(NVarcharColumn AS BIGINT)WHERE ISNUMERIC(NVarcharColumn) = 1

That would convert those rows that can be converted - the others need to be dealt with manually.


You should convert bigint to nvarchar not vice versa cast(Other_Column_name as nvarchar) not cast (Column_Name as bigint)


you can try this:

CAST(CAST(col1 as NUMERIC) as BIGINT)