Showing posts with label alter. Show all posts
Showing posts with label alter. Show all posts

Tuesday, March 6, 2012

About the presence of alter procedure?

Is it a good practice to leave the alter procedure statement in a stored
procedure? Does it affect the execution in any way? Is it common to comment
the statements out until needed again?
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/I'm a bit . Where would you remove it from? Once the procedure is
altered, the "ALTER" is not really there anymore.
To illustrate this, try the following on your end:
CREATE PROCEDURE proc_x
AS
RETURN
GO
ALTER PROCEDURE proc_x
AS
RETURN 1
GO
SELECT ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_NAME = 'proc_x'
GO
DROP PROCEDURE proc_x
GO
--
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> wrote in message
news:utDcT6WnGHA.1592@.TK2MSFTNGP04.phx.gbl...
> Is it a good practice to leave the alter procedure statement in a stored
> procedure? Does it affect the execution in any way? Is it common to
> comment the statements out until needed again?
> --
> <%= Clinton Gallagher
> NET csgallagher AT metromilwaukee.com
> URL http://www.metromilwaukee.com/clintongallagher/
>

Thursday, February 16, 2012

About ordering of columns

i add new column using alter command but i always found it in the end of table but
i want to add it in particular position between the columns.........
how to do so ..........:)The only way to do that is dropping the table and recreating it with the columns in the position you want.

But why do you want to do this? Column order has no significant meaning in the database and can be arbitrarily changed in the the statements you use.|||I think if you use EM or SSMS to add a column you can add a column to the middle as well, but this likely does just what lexiflex suggests under the covers.

I agree with lexiflex: why do you care? The only reason I can think of is you are using "select *" in your app code, which is a no-no.|||You CAN move columns around in EM when in table design view. Just drag
the column to the position you want, and save the design.

ummmm... I would NEVER do this, I just saw somebody else do it (heh heh)|||You CAN move columns around in EM when in table design view. Just drag the column to the position you want, and save the design.but under the covers, EM creates a new table, copies the data from your original table, and then drops it|||EM creates a new table, copies the data from your original table, and then drops it
Which brings me to another reason for not using EM and making scripts yourself...

Try adding a NOT NULL-column without a default somewhere in between the other columns. Running the EM-script will cause an error about NULL-values in NOT NULL-columns just before it drops your original table and renames the temp-table. Thus making all the data from that table magically disappear... :S|||You CAN move columns around in EM when in table design view. Just drag
the column to the position you want, and save the design.

ummmm... I would NEVER do this, I just saw somebody else do it (heh heh)
I freely admit to doing this all the time.
Why? Because I like my data columns in logical groups, thats why.
But why do you want to do this? Column order has no significant meaning in the database and can be arbitrarily changed in the the statements you use.Absolutely correct. The database does not care about column order. But PEOPLE do...