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

Nicholson, Karen knicholson at gpsx.net
Wed Oct 29 14:28:36 CST 2003


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


More information about the dba-SQLServer mailing list