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.
| Author |
Topic |
|
SLM09
Starting Member
31 Posts |
Posted - 2011-01-13 : 13:36:48
|
| Hi all,I am almost positive I have seen this before and curious how it is done. If you have a cell with 100 in it, you could then have a varchar cell with "<200". In a where statement, you could then utilize the second cell as part of the code itself. Ie- something like where A something(B)I could write a custom function to break down the contents of B (and maybe thats what I saw done before), but I was curious if there was already logic to do this.Thanks |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-01-13 : 14:03:51
|
| Cells exist in spreadsheets, not in SQL. You are confusing the two tools.A table is a set of rows; the rows have no order. Rows are made of columns; columns have no order. The values in a column are scalars drawn from a domain. Values are not code. Really bad SQL programmers will use a table with VARCHAR(n) strings and dynamic SQL to write unmaintainable, slow code that mimics spreadsheets. If this was a woodworking newsgroup and someone posted "What is the best kind of rocks to pound screws into fine furniture?" are you really helping them when you say "Granite! Use big hunks of granite!" I am the guy who replies with "Your question is bad. Don't you know about screwdrivers?" And I like to remind them that it takes six years to become a Journeyman Union Carpenter in New York State. Not Master, Journeyman. --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-01-13 : 14:45:34
|
quote: columns have no order
Not correct. In SQL Server, columns do indeed have order. |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-01-13 : 14:55:19
|
quote: Originally posted by russell
quote: columns have no order
Not correct. In SQL Server, columns do indeed have order.
I don't want to put words into Joe's mouth, but I think he means in a mathmatical sense (Symmetric Property).SELECT A, B ..Is the same asSELECT B, A ..The order does not affect the meaning or values of A or B.But, yes columns do have an ordinal postionin MS SQL. |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-01-13 : 15:02:06
|
Someone should remove a few words from his mouth |
 |
|
|
SLM09
Starting Member
31 Posts |
Posted - 2011-01-13 : 15:58:27
|
| I am looking into different ways to build a dynamic rules engine in SQL. What I found and wanted to test out was a 3 table structure. One table has the records that the rules will be applied too. One will be a reference table pertaining to a "set of rules". The third table having the individual rules broken down for each records.The idea basically would be my third table may have something likeRuleID = 1, Field = Location, Rule = '="CA"'RuleID = 1, Field = Pay, Rule = '>40000'The idea is the ref table knows both of these rules pertain to 1 "rule set". Dynamically, the code could then piece together the rules to bump against the data table Where location = 'CA' and Pay > 40000This is just an idea as a single ruleset can have who knows how many parts to grow, and across dozens of fields. Also, we want this to be easily managed once the original tables are built. I have found numerous ways to do this (case statements are easiest, custom functions, pre-made toolsets), I was simply curious how this would work, and the speed in which it would compile data.Thanks |
 |
|
|
|
|
|
|
|