top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

convert NCHAR data type to INT

0 votes
237 views

How do i convert NCHAR data type to INT in sql server?

posted Apr 18, 2014 by Khusboo

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

CREATE TABLE #Table(test nchar(3))

INSERT INTO #Table SELECT '111'

INSERT INTO #Table SELECT 'AAA'

INSERT INTO #Table SELECT '311'

SELECT CASE ISNUMERIC(test) WHEN 1 THEN CAST(test as int) ELSE 0 END FROM #Table

DROP TABLE #Table

answer Nov 12, 2014 by Manikandan J
Similar Questions
+3 votes

How to convert c # inline queries into stored procedure written in transact sql?

+3 votes

I have a table that looks something like this:

SetId ID Premium 
2012 5 Y 
2012 6 Y 
2013 5 N 
2013 6 N

I want to update the 2013 records with the premium values where the setid equals 2012.
So after the query it would look like this:

SetId ID Premium 
2012 5 Y
 2012 6 Y 
2013 5 Y 
2013 6 Y

Any help greatly appreciated

...