x
login about faq Site discussion (meta-askssc)

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 '12 at 03:36 PM in Default

devino1 gravatar image

devino1
0 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 '12 at 07:37 AM

Kev Riley gravatar image

Kev Riley ♦♦
46.1k 38 43 69

(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.

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



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x6

asked: Sep 01 '12 at 03:36 PM

Seen: 438 times

Last Updated: Sep 03 '12 at 07:37 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.