SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Column Data type issue


Column Data type issue

Author
Message
Thamizh
Thamizh
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 520
Dear SSC,

I have a Decimal column.I'm not authorized to change the column data type.My data will be positive or negative value.What i need is, if the value will be negative means those data having prefix with "-" symbol but not in the Positive value.I want to insert the data with "+" symbol in the decimal column.
Is there any solutions?
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10605 Visits: 13559
Thamizh (3/3/2010)
Dear SSC,

I have a Decimal column.I'm not authorized to change the column data type.My data will be positive or negative value.What i need is, if the value will be negative means those data having prefix with "-" symbol but not in the Positive value.I want to insert the data with "+" symbol in the decimal column.
Is there any solutions?

No.
The decimal data type will display the '-' for negative numbers, but not the '+'.
I'd recommend to do it at the frontend side. If required to convert it with SQL server you'd need to change it to a character value and add the '+' notation with a CASE statement. I don't recommend it though...



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Paul White
Paul White
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16284 Visits: 11355
Seems an odd requirement, and the wrong place to do it as Lutz mentions.
Nevertheless...
DECLARE @Demo
TABLE (
data DECIMAL(5,2) NOT NULL,
odd_format AS
CASE SIGN(data)
WHEN -1 THEN CONVERT(VARCHAR(7), data)
-- Assumes zero is 'positive'
ELSE '+' + CONVERT(VARCHAR(7), data)
END
PERSISTED NOT NULL
);

INSERT @Demo (data)
SELECT TOP (20)
CHECKSUM(NEWID()) % 99999 / 100.0
FROM master.sys.all_columns;

SELECT *
FROM @Demo;



Paul



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Thamizh
Thamizh
SSC Rookie
SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)SSC Rookie (49 reputation)

Group: General Forum Members
Points: 49 Visits: 520
No friends ,If i authorized for that means i will concatenate or alter the column .
But my seniors not allowed for that.That's y I'm asking
Paul White
Paul White
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16284 Visits: 11355
If you're not authorized to change anything, it can't be changed Laugh

Do it application-side, or explain yourself clearly, and provide a valid reason for doing this.

Paul



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search