all groups > sql server mseq > july 2006 >
You're in the

sql server mseq

group:

Data in wrong columns after query changed


Data in wrong columns after query changed JerryWendell
7/24/2006 6:56:02 AM
sql server mseq: I added a field to the middle of an existing query. Another query that
referenced the changed query had data in the wrong columns.
For example, the original query had
TaskID, division, CostID, Amount
I changed it to have
TaskID, division, company, CostID, Amount
When I executed a query that referenced the changed query, CostID was
displayed in the company field and Amount was displayed in the CostID field.

The only way I found to correct the problem was to go into every query that
references the changed query and make a change and save it. This could be
cumbersome if there are a lot of queries involved.

Is there a way to force all queries to be saved or some other way to get
SQLServer to recognize the change?

RE: Data in wrong columns after query changed JerryWendell
7/24/2006 7:24:02 AM
I should clarify that the second query (the one that references the changed
query), uses the "*" to select all columns from the first query.

[quoted text, click to view]
Re: Data in wrong columns after query changed Arnie Rowland
7/24/2006 8:20:21 AM
Of course that is the problem.

That's the main reason that we encourage the practice of explicitly 'naming'
the desired columns in every query. Most of us here constantly tell folks
that using "SELECT *" is inappropriate and places the queries in jeopardy of
failure (or producing inappropriate results) in the future.

If all of your queries were properly written, and listed the columns
desired, queries would not fail as a result of adding a new column, or
changing the column order. They just wouldn't deal with the now missing
'new' column and could be corrected as needed.

Also, good programming practices REQUIRE that you never change existing
procedures in a way that will 'break' other functionality. In the rare
circumstance where it is necessary to deliberately break existing
functionality, a complete test regimen and user acceptance cycle must be
invoked again.

There is no 'quick fix' for your problem. You have no alternative but to
manually find and repair all queries so affected. And in the process, you
may inadvertently 'break' other things. As the tag line below indicates,
chalk this one up to 'experience'.

--
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


[quoted text, click to view]

AddThis Social Bookmark Button