Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert or cast int to string in SQL Server

Tags:

sql

sql-server

Looking at a column that holds last 4 of someone's SSN and the column was originally created as an int datatype. Now SSN that begin with 0 get registered as 0 on the database.

How can I convert the column and it's information from an int into a string for future proof?

like image 238
Cookies Avatar asked Oct 27 '25 23:10

Cookies


1 Answers

You should convert. CONVERT(VARCHAR(4), your_col)

like image 106
Carlos Alves Jorge Avatar answered Oct 30 '25 13:10

Carlos Alves Jorge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!