Sparse columns or normal columns? - sql-server-2008

I have 6 columns of date-time type in a table. My application has a requirement that each column should have additional column one for validation that can be of a bit datatype and another modified date-time if user wants to modify it. So my question is that is there any thing better than adding 2 column for each column I have? Also I know about Sparse columns which I can use to save my table space but still is there any thing better I can do??
The 'Bit' Logic
So there are 3 columns
original datetime,
modified datetime and
Validation bit.
Validation bit is by default set to false. When user want to change the date-time then modified date-time column will be updated with new value; however, there will be no change in original date-time column. Now user has to make decision whether value being entered is validated or not. The validation bit will decide this functionality.

I would disable the Valid checkbox until they enter a modified date. Sparse for those two columns works.

Related

Updating one table in MS Access with data from another

In MS Access 2016 I have a table named Master that periodically needs to gets updated with ‘updated’ data from a table named NewData. Each table has the same fields, except Master has one additional field named OTHER_SOURCES (explained further down). They each have an indexed unique id field named EVENT_ID. I’ve built an update query where the tables are joined one-to-one on the EVENT_ID field. In this query I have the fields in Master getting updated to the new values from the same fields in NewData if the TIMESTAMP field value is different. If the TIMESTAMP values haven’t changed, then those records do not get updated. This part is pretty straightforward and works fine.
However, I have end users that may make occasional changes to the values in the SIZE field of Master that need to be preserved and not overwritten with updated values from NEW_DATA. When a user makes a change in SIZE field, he documents the change with information obtained from other sources, which is stored in the extra field I mentioned earlier: OTHER_SOURCES. Here’s what I need to do, and I just can’t figure it out. Whenever a user has made a change to the SIZE field for a record, I need the update query to not override that value in the SIZE field, but still update the values in all the other fields (again, assuming the TIMESTAMP values are different between the two tables). It seems I need to use an IIF statement, but I’m thinking it needs to be done in VBA where I’m a bit of a hack. See screenshots. I greatly appreciate any help you can offer.
enter image description here
enter image description here
You can still proceed with the update, but update it to the same value as its previous value:
SET SIZE= IIF(nz(OTHER_SOURCES,'')<>'', MASTER.Size, NEW_DATA.Size)
This assumes that anything present in the MASTER.OTHER_SOURCES column indicates that the user has changed MASTER.Size. Note that MASTER.Size will never be updated from NEW_DATA.Size until someone (end user) removes MASTER.OTHER_SOURCES.

How to customize TaxReport_IT - report SSRS?

I would like to custom the Report SSRS TaxReport_IT, I need to add a new field in order to use in to SyntethicReport Design.
(for example)
The classes involved seems these:
TaxReport_IT
TaxReportDP_IT
TaxReportController_IT
TaxReportContract_IT
Tables involved:
TmpTaxReport_ITSummary
TmpTaxReport_IT
TaxReportTmp_IT
Are there others? Are there some Queries involved?'
I added the new fields in to table _TmpTaxReport_IT_, and I pupulated the related tables
I'm sure, in to the method I pupulated correctly the new Field (I have the values ​​that I expect), but when I print the Report I get a lower value. Seems like I don't take the total data set.
How can I add the new field and take the correctly total value?
I saved the data (about my custom field in a RegularTable) and the sum is correct, but I have mismatch when I print the report.
I think I skip some step to Report DataSet.
I use Dynamics AX 2012.
Thanks in advice!
I have an idea what could be wrong, but I'm making some assumptions. If they are not correct, please edit your question to clarify.
From your screenshot, it looks like you want to add your new custom field in the header section of the report design. I'm assuming the expression of that field looks similar to
=First(Fields!MyCustomFIELD.Value, "TaxReportDS_IT")
Note the First key word in that expression. This indicates that the value for that field should be taken from the first of the records of the report's dataset.
I'm assuming that you calculate the value of the field while the records in table TaxReportTmp_IT are being created so that each record has a different value. Maybe it is a sum of some other field, so the first record would have the smallest value and the last record the highest.
If all those assumptions are correct, you can fix this by changing the First keyword to Last. This indicates that you want to take the value of the last record of the report data set.
See also the documentation of the Last Function.

Use a another table's column's value as the name of a table in a join statement

First, I'll ask the question:
Is it possible to make a value's type 'dynamic' by creating different tables with different value types and use a simple join query to fetch the correct table based on the type specified in a column?
Here is the context:
I'm building a sort of page builder where I want the "modules" to be dynamic in the sense that I can create new modules without having to modify the database in any way.
I envision 4 entities:
A field, which represents a single value of a specific type, for example a text field or a checkbox;
An entry type, which represents a group of fields to be used for an entry. For example, Article = Title + Content + Image.
An entry, which is the content defined by the corresponding entry type.
A value, which contains the data for one field for one entry, defined by the field's value type.
For the 'value' entity, I was planning on using multiple tables for each "type of value". "value_text", "value_integer", "value_boolean", etc.
What I wanted to do (and I think it's an anti-pattern in relational database) was to grab a value in the fields table to select the proper "value" table.
Here is an image of the structure I envisioned:
(imgur) UML Diagram of DB
So I'm looking for a way to make a single query to fetch the correct value for each field of a specific entry (by ID).
This means I have to access the assigned entry_type, fetch all the fields related to that entry_type, then fetch the value of each of those fields from the value tables based on the column 'value_type' of the fields table.
If this is possible, how can I achieve this? If it's not possible, what would be the best way to tackle this problem:
Make a first query to retrieve the fields, then a query for each field to grab the correct value? This makes a lot of queries to get the values of a single entry...
Modify the structure of the database to a more efficient set of relations, taking into account everything is dynamic...
Get rid of the idea of using mutiple "value types" and stick to using a more common everything-is-serialized-text approach.
Also, as this is one of my first questions on StackOverflow, please let me know if I asked incorrectly and how I should formulate this in the future.
Thanks for all of you who even take the time to read this :)

Sorting a Column of String Values Representing Numbers in Access (VBA)

The Scenario: I have a table In Access that has a column of type text but contains numerical values that needs to be sorted in a descending order.
The Issue: I tried doing a query and specifying the order in the design view, but the results are being sorted based on the first digit and not the whole number.
When I tried to change the type of the column from text to numeric, I received a warning some data will be lost and also the sorting yielded wrong results.
The Question: Any suggestions about how to solve this issue?
Note: I am importing the data from an excel sheet where the column is of type standard.
I find no datatype NUMERIC in the Access SQL documentation. If data will be lost, you use a datatype that is too small for the converted values. Probably use FLOAT, a double precision floating point value. You could add a FLOAT column to your table and then UPDATE that field of the table from the text field. This will preserve your old values and lets you check for any non-converted values.
UPDATE myTable SET float_field=text_field;

viewing underlying value in access lookup field

If I have a lookup field in Access with the first (bound) column hidden by setting field widths to 0";1", is there a way to see the real underlying value of the field without having to change the formatting of the lookup column?
I don't believe there is a way to access the available values without editing the lookup column.
With that said, I would point out the following:
Changing the formatting of the lookup column only impacts 2 things.
When you navigate the records from the table view you will see the new definition.
Any forms created in the future will now inherit the new definition.
In other words, changing the formatting of the lookup column doesn't impact any forms you may have already created based upon that field.
You can have a more descriptive description in your table that is completely separate from the definition in your forms.
If you want to know all of the values I suggest that you edit the drop down to show a concatenation of columns 1 and 2.
For example, lets say you had a value list of
1;foo;2;bar
The value list could be changed to
1;1-foo;2;2-bar
Then you know at a glance what the "hidden" field value represents. (The same could be done if the record source is a query.)
Turns out that there is a very simple way to do it. In the query, go to field properties and click on the "Lookup" tab, and choose textbox.