dbTalk Databases Forums  

Saving changes

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Saving changes in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Allie
 
Posts: n/a

Default Saving changes - 11-20-2007 , 02:19 PM






Hi, all.

This might be a silly question... but I am very new to programming in
SQL so please bear with me

So. I'm using MS SQL Server 2005 Management Studio Express. I have a
table that was created via an existing .sql file. Included were a
bunch of stored procedures. I went in to re-format these procedures.
(They were written in haste by another programmer. It is my task to go
back and improve their readabilities.) However, I am having difficulty
figuring out how to save the changes to these stored procedures. Thus
far, I have been individually saving each stored procedure in its
own .sql file. This is obviously not the way to go... but it's a
temporary solution (so as not to lose the changes I have made to
dozens of procedures).

Can someone please explain to me how I commit these changes to the
database?

Thanks,
Allie

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Saving changes - 11-20-2007 , 04:40 PM






Allie (fakeprogress (AT) gmail (DOT) com) writes:
Quote:
So. I'm using MS SQL Server 2005 Management Studio Express. I have a
table that was created via an existing .sql file. Included were a
bunch of stored procedures. I went in to re-format these procedures.
(They were written in haste by another programmer. It is my task to go
back and improve their readabilities.) However, I am having difficulty
figuring out how to save the changes to these stored procedures. Thus
far, I have been individually saving each stored procedure in its
own .sql file. This is obviously not the way to go... but it's a
temporary solution (so as not to lose the changes I have made to
dozens of procedures).
I think that is exactly the way to go. You should also put the files under
source control.

Quote:
Can someone please explain to me how I commit these changes to the
database?
But that's not saving. You save a file to the file system, and as I said,
you also put it under version control.

To change the database what's in the database is more akin to a compilation.
To make this easy to handle, I suggest that you have this in your files:

IF object_id('my_sp') IS NULL
EXEC ('CREATE PROCEDURE my_sp AS SELECT 1')
go
ALTER PROCEDURE my_sp -- real code follows here

Then it doesn't matter when you run the file, whether the procedure
exists or not.

And to run the file from Mgmt Studio, you can clich the green arrow,
or press CTRL/E or F5.

When you need to load several files, this is more convenient to do
from a BAT file and use SQLCMD instaead.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.