[dba-SQLServer]A real Newbie Queston re:updating a Field in a Table

Susan Geller sgeller at cce.umn.edu
Thu Oct 30 10:36:43 CST 2003


Actually, even if you don't create a sproc, you can still keep whatever
you type in Query Analyzer.  Just save the document like you would a
word document.  It gets saved as a .sql file and then you can open it
anytime in Query Analyzer if you want.  I have lots of stuff that I save
like this because I don't want it cluttering up my database, but I want
to save the work that I've done.

--Susan


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of
Nicholson, Karen
Sent: Wednesday, October 29, 2003 2:29 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer]A real Newbie Queston re:updating a Field in
a Table


If you create a stored procedure, then you can always just open up query
analyzer and execute the stored procedure without having to retype it.
You can also schedule a stored procedure to run by creating a job (under
management, sql server agent, jobs.

If you just type it into the query analyzer, it is a one time shot and
boom it is gone, making you retype it if you want to run it again, or
worst yet, forgetting how you did it (which happens all the time when
learning) and wasting time.

-----Original Message-----
From: Klos, Susan [mailto:Susan.Klos at fldoe.org]
Sent: Wednesday, October 29, 2003 3:19 PM
To: 'dba-sqlserver at databaseadvisors.com'
Subject: RE: [dba-SQLServer]A real Newbie Queston re:updating a Field in
a Table


I think I would like to go the Stored Procedure way as that is what I
think most programmers do.  What is the difference between the two?

-----Original Message-----
From: Nicholson, Karen [mailto:knicholson at gpsx.net]
Sent: Wednesday, October 29, 2003 3:05 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer]A real Newbie Queston re:updating a Field in
a Table


You know, you dont really hav to create a stored procedure.  I am just
so used to doing that.  You could just put in the code in the query
analyzer. Sorry about that, I am programmed to create stored procedures.

-----Original Message-----
From: Nicholson, Karen [mailto:knicholson at gpsx.net]
Sent: Wednesday, October 29, 2003 3:00 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer]A real Newbie Queston re:updating a Field in
a Table


This would be in a stored procedure.  
Create a new stored procedure such as:

create stored procedure gps_update as
update dbo.prospect
set dbo.prospect.udf12='myvalue'
FROM  dbo.prospect INNER JOIN
      dbo.customer ON dbo.prospect.cust_no = dbo.customer.cust_no

Then, from SQL server, go up to TOOLS.
Selected SQL query analyzer.

A new window opens.  Make sure that you select the correct database from
the drop down box.
Type:
exec gps_update

Then hit the green arrow to run the procedure.

Your stored procedure will run.

-----Original Message-----
From: Klos, Susan [mailto:Susan.Klos at fldoe.org]
Sent: Wednesday, October 29, 2003 2:52 PM
To: 'dba-sqlserver at databaseadvisors.com'
Subject: RE: [dba-SQLServer]A real Newbie Queston re:updating a Field in
a Table


This is really going to show my ignorance.  Do you put the sql code in a
new view?  If not, where?

-----Original Message-----
From: Nicholson, Karen [mailto:knicholson at gpsx.net]
Sent: Wednesday, October 29, 2003 10:39 AM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer]A real Newbie Queston re:updating a Field in
a Table


Here is an example - I have a prospect and a customer table.  Join them
by their common field, cust_no. Update the field you want to update (I
used udf12) to the desired value.


update dbo.prospect
set dbo.prospect.udf12='myvalue'
FROM  dbo.prospect INNER JOIN
      dbo.customer ON dbo.prospect.cust_no = dbo.customer.cust_no

-----Original Message-----
From: Klos, Susan [mailto:Susan.Klos at fldoe.org]
Sent: Wednesday, October 29, 2003 10:13 AM
To: 'dba-SQLServer at databaseadvisors.com'
Subject: [dba-SQLServer]A real Newbie Queston re:updating a Field in a
Table


I have two tables which are inner joined on two fields.  One of the
tables contains a flag field.  I want to update the flag field only
where records in the two tables are the same.
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com



More information about the dba-SQLServer mailing list