Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Pass Through Query

Author  Topic 

mase2hot
Starting Member

36 Posts

Posted - 2010-04-27 : 16:57:57
I have a stored procedure as below for when I print out application packs in access it does a passthorugh query to the below. The problem is that when it runs it updates teh pack out dat for the whole database. How can I get it to only update the ones which are printed?

My pass though query is simply "exec dbo.pack_out". I guess I need to refer to the ID Primary key of the table but where?


UPDATE dbo.Progress
SET Pack_Out_Date = GETDATE()

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2010-04-27 : 17:04:39
please illustrate what your sp does.. simply update table set col = value will update the entire table if no WHERE filter defined.
Go to Top of Page

mase2hot
Starting Member

36 Posts

Posted - 2010-04-27 : 17:49:07
Thecode I pasted is the only code in my stored procedure, I can see its incorrect as its simply saying update all of column pack_out_date to current date. What do I specifiy in the where clause? I'm just thinking if I put "where pack_out_date is null" would that be ok?
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2010-04-27 : 17:53:16
Really depends on what are you trying to achieve with the update. If you want to update the pack_out_date when its NULL then yes, you should put where pack_out_date is null.
Go to Top of Page

mase2hot
Starting Member

36 Posts

Posted - 2010-04-27 : 18:08:36
cheers all sorted now.
Go to Top of Page
   

- Advertisement -