I need to convert a numeric value to nvarchar in sql command.
Can anyone please help me.
The database server does not pad a numeric value in an NVARCHAR column with trailing blanks up to the maximum length of the column.
Converting int to string/varchar using Cast() So, in the above example, we have declared a variable of integer data type and assigned a value to the variable. After this, we are using the Cast() function to convert the variable to the varchar data type of length 10. And the query will return the following result.
TO_CHAR (number) converts n to a value of VARCHAR2 datatype, using the optional number format fmt . The value n can be of type NUMBER , BINARY_FLOAT , or BINARY_DOUBLE . If you omit fmt , then n is converted to a VARCHAR2 value exactly long enough to hold its significant digits.
select convert(nvarchar(255), 4343)
Should do the trick.
declare @MyNumber int set @MyNumber = 123 select 'My number is ' + CAST(@MyNumber as nvarchar(20))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With