Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Percentages?

Author  Topic 

JeffK627
Yak Posting Veteran

50 Posts

Posted - 2010-04-07 : 15:10:40
Hi all, I have been given this business rule to enforce in the database: "Additonal Tax Amount must be a dollar amount. (Percentages are not valid.)". The data does not contain dollar signs or percent signs. How the heck am I supposed to code this in SQL??

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-07 : 16:47:06
What is it you're actually doing? Are you adding a new column to a table to store the Additonal Tax Amount? Are you writing a query to calculate the Additonal Tax Amount?

In any case, keep in mind that formatting data (By adding a $ sign or % sign) is something that's usually done in the application layer, not the database layer.

There are 10 types of people in the world, those that understand binary, and those that don't.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-08 : 01:08:03
are you told to do this at back end? or it may be that you can impose this at your front end

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

JeffK627
Yak Posting Veteran

50 Posts

Posted - 2010-04-08 : 09:48:46
Nope. The data arrives in a flat file and in loaded into the table. They want me to determine whether the Additonal Tax Amount column is a dollar amount or a percentage for each record and write a query so that the percentages fall out. It's a column of numbers, how the $#@! am I supposed to tell whether they're dollars or percentages?

Of course, the business clients don't want to hear this because they're not technical. They just want what they want.
Go to Top of Page

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-08 : 10:07:12
quote:
Originally posted by JeffK627
It's a column of numbers, how the $#@! am I supposed to tell whether they're dollars or percentages?

If each individual value in that column can be either a dollar amount or a percentage, and there's no indication as to the meaning of each value, (eg, $ or %, or some other flagging column), then there's really no way to be sure.
quote:
Of course, the business clients don't want to hear this because they're not technical. They just want what they want.

Then ask them, "27, is that a dollar amount, or a percentage?" When they can't answer the question, then tell them, that's why they can't have what they want.

Is there anything else in the source data that was used to create the flat file, which could be added to the flat file to indicate the meaning of that column for each record?

There are 10 types of people in the world, those that understand binary, and those that don't.
Go to Top of Page

JeffK627
Yak Posting Veteran

50 Posts

Posted - 2010-04-08 : 10:51:07
Nope, they're just going to have to accept the news they don't like. I'll let my Manager deal with it. ;-)
Go to Top of Page

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-08 : 11:03:00
quote:
Originally posted by JeffK627
I'll let my Manager deal with it. ;-)



That's what they're good for.

There are 10 types of people in the world, those that understand binary, and those that don't.
Go to Top of Page
   

- Advertisement -