Microsoft Access is Still Extremely Useful

November 12, 2007 22:15 by Dominick

Part of my new job has been to automate a few spreadsheets and joining data from separate systems. I'm much more comfortable working in ASP.NET, but I have a lot of background with MS Access so I don't mind at all. In fact its nice to "go back" a little and see how quickly you can do simple things in Access. You can set up tables, queries and forms in minutes. The built-in wizards make creating a basic form in a crunch very easy. The reporting component is extremely powerful. It has its limitations, of course, but with a little hacking you can get it to do that Gantt chart you needed or some crazy conditional formatting if you must. There haven't been many times where I"ve had to go outside of Access to build a report. Mostly roll-your-own type of things.

Its refreshing to jump into Access, create a couple tables or import data from Excel, run the form creation wizard and your done. You now have an easy way to navigate through your records and the ability to change the data within the form.  In ASP.NET you've got to jump through a few hoops to get to that point (SubSonic's wonders aside). Using Access for non-authenticated forms and reports in a pinch is a fantastic alternative to a full-blown ASP.NET application. Its unmatched in its RAD capabilities and most people in your office will already have it installed on their PC. 

Its refreshing to jump into Access, create a couple tables or import data from Excel, run the form creation wizard and your done.

There are many times when creating a web-based application just isn't possible so using Access to merge some data is the way I look to go in those cases. Most people are already familiar with the standard Access forms and reports so the learning curve is fairly low. Don't depend on Access as your backend for a many-user environment because you will be flirting with disaster, but that wasn't the reason Access came into being. Use it for what it was meant for. Rapid application developement, prototyping and reporting.


kick it on DotNetKicks.com

Tags:
Categories: SQL | Database | MS Access | General
Actions: E-mail | Permalink | Comments (5) | Comment RSSRSS comment feed


Concatenate Column Values from Multiple Rows into a Single Column in SQL Server

October 11, 2007 11:46 by Dominick

What I needed to happen


There is likely many other more efficient ways to accomplish this, but this is the way I figured out how to do it in my particular situation. I needed to be able to combine column values in a table into a single column to be able to do a filter or search. I'll show you what I mean.

First Table 

 

RecordIdName
1001Sandy
1002Tom
1003Jim

Second Table

This table stores multiple records for each person.

RecordIdFieldtoConcat
10011
10012
10021
10023
10031
10032
10033


I needed to have this data set returned so I could then filter the list by search for each "FieldtoConcat" in the list.

RecordIdNameConcatedFields
1001Sandy^1^^2^
1002Tom^1^^3^
1003Jim^1^^2^^3^


The first question you may ask is what's up with the "^". Its a simple reason. If there were any records with a value of, say, "10" when I would search for just "1" then I would get all the records that had "1" in them. So my solution was to search for "^1^" which would ensure that I would only get the desired records.

How to do it


To pull this off you need to create a function. Here it is:

CREATE FUNCTION [dbo].[ConcatField](@RecordId int)
RETURNS VARCHAR(1000)
AS
BEGIN
    DECLARE @ReturnValue VARCHAR(1000)
    SET @ReturnValue = ''

    SELECT @ReturnValue =    CASE @ReturnValue
                WHEN '' THEN '^' + CAST(FieldtoConcat AS VARCHAR(3)) + '^'
                ELSE @ReturnValue + '^' + CAST(FieldtoConcat AS VARCHAR(3)) + '^' 
                END
    FROM TableWithTheFieldtoConcat
    WHERE Id = @RecordId
    ORDER BY FieldtoConcat

    RETURN @ReturnValue
END


It takes the RecordId as a parameter, combines all the numbers into @ReturnValue and returns the values as desired.

After that it gets easy.  I'll just show you the SQL because it's pretty self explanatory.

SELECT     RecordId, Name, CAST(ConcatField(RecordId) AS VARCHAR(1000)) AS ConcatedFields
FROM         FirstTable


You can insert a "WHERE ConcatedFields LIKE %^1^%" and it will only pull the records with "1". That's all there is to it. Anybody have a better way? Please comment.



kick it on DotNetKicks.com

Technorati Profile

Tags:
Categories: SQL | General
Actions: E-mail | Permalink | Comments (6) | Comment RSSRSS comment feed