[Wolves] SQL sound off!

Jayne Heger jayneheger at gmail.com
Sat Mar 19 17:37:53 GMT 2005

Hello All,

Hope you are all ok! :-)

Anyway, I am sounding off something I have to do at work soon, to see
if it makes sense!

First the scenario,
We have 3 tables used in this scenario
One is a calendar table which contains months and years like Jan05, Feb05 etc,

The other is a table which is created on the fly,using these months as
fieldnames for some of the fields.
Now, someone wants these months to have dashes in them, like Jan-05,
Feb-05 etc..

What we have is a CURSOR which loops through the calendar monthsyears
and alters the table that is created dynamically to put them as
So having a dash in the month is not a problem for display purposes,
it only becomes a problem when later on we want to insert data to that
As we do
FROM Table2

If I left that as is, it would fail as the newly created table would
have dashes in the fieldnames and you have to have square brackets
aound them, which is now what I am trying to work out the best way of
doing this
Bearing in mind, the fieldnames are created dynamically for the months
through what is in the calendar table,
and I'm not sure if it is always 12 months we display (will find out Monday),

So what I am thinking is using that CURSOR which finds the months,
building up the INSERT statement dynamically
like INSERT INTO Table (@Month1, @Month2) etc, etc

how does that sound?

Yes, yes, I know having a dash or any other funny character in a
fieldname is a Big No No but it has to be done for various reasons
which I can't go into.

On a completely different note, who is going to the Dimebag Darrell
concert at Eddies? I've already got my tickets, and at least one of my
friends plus my better half Jim is going, should be fun!

Anyway, see you,
will get to a meeting soon I promise, just been knackered, all this
travelling around is wearing me out. :-)


More information about the Wolves mailing list