x

Update Float to Nvarchar

New to SQL and I have a table with a SSN column that is a float data type and need to change it to nvarchar. Ran the following:

select dbo.ValidSSN(cast(SSN as bigint)), * from temp.__do_metroair

  SSN                                    SSN

(before the Select) (after the Select)

780210101                           780200000000
100110010                           100100000000

Need the SSN column at 9 digits and nvarchar. Also, looking for the update statement to make the change.

,
more ▼

asked Sep 01, 2012 at 03:36 PM in Default

devino1 gravatar image

devino1
0 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Casting values such as you've shown into a nvarchar(9) shouldn't be an issue - what is the function dbo.ValidSSN doing - can you post the code?

DECLARE @SSN FLOAT
SET @SSN = 780210101

SELECT @SSN, CAST(CAST(@SSN AS BIGINT) AS NVARCHAR(9))
more ▼

answered Sep 03, 2012 at 07:37 AM

Kev Riley gravatar image

Kev Riley ♦♦
53k 47 49 76

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x7

asked: Sep 01, 2012 at 03:36 PM

Seen: 969 times

Last Updated: Sep 03, 2012 at 07:37 AM