question

devino1 avatar image
devino1 asked

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. ,
nvarchar
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
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))
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.