Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert numeric to nvarchar in sql command

I need to convert a numeric value to nvarchar in sql command.

Can anyone please help me.

like image 990
Arun Avatar asked Dec 07 '11 06:12

Arun


People also ask

Does nvarchar accept numbers?

The database server does not pad a numeric value in an NVARCHAR column with trailing blanks up to the maximum length of the column.

Can we convert int to varchar in SQL?

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.

Can we convert number to char in SQL?

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.


2 Answers

select convert(nvarchar(255), 4343) 

Should do the trick.

like image 135
Olivier S Avatar answered Sep 25 '22 23:09

Olivier S


declare @MyNumber int set @MyNumber = 123 select 'My number is ' + CAST(@MyNumber as nvarchar(20)) 
like image 42
Chris Fulstow Avatar answered Sep 23 '22 23:09

Chris Fulstow