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

avatar 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

avatar image

Kev Riley ♦♦
63.8k 48 61 81

(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

SQL Server Central

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

Topics:

x10

asked: Sep 01, 2012 at 03:36 PM

Seen: 1183 times

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

Copyright 2016 Redgate Software. Privacy Policy