Carlos80
Carlos80

Reputation: 433

SQL add text to numeric column

I'm not sure if this is even possible but I have a query that joins two table and compares two data sets, current month vs previous month. Where I have new data the previous column produces a Null.

I have been trying to replace NULL with the text 'New Account'. However I am aware that I am trying to force a text value into a numeric column.

So I'm just wondering if this is even possible as I haven't found anything online to help.

Thanks in advance.

Upvotes: 0

Views: 1687

Answers (1)

John Cappelletti
John Cappelletti

Reputation: 81970

Just to expand on Gordon's and Larnu's comments.

No, you can't UPDATE a numeric column with text. You can, however, change the final presentation of the value.

Please note that the final result is a string and not a numeric value.

Example

Declare @YourTable table (SomeCol int)
Insert Into @YourTable values
 (25)
,(null)

Select SomeCol = coalesce(left(SomeCol,10),'New Account')
 From  @YourTable

Returns

SomeCol
25
New Account

Upvotes: 3

Related Questions