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.
Author |
Topic |
magmo
Aged Yak Warrior
558 Posts |
Posted - 2014-03-26 : 04:52:42
|
HiI have 2 tables, "order" and "orderrows"table "orderrows" look like this...OrderName (nvarchar 50)ArticleID (int)Qty (int)IsFetched (bit)table "order" look like this...OrderName (nvarchar 50)Adress (nvarchar)IsFetched (bit)I would like to create a stored procedure that pass the OrderName as parameter and then check if all "IsFetched" = 1 in the "orderrow" table, if so update "IsFetched" to 1 in table "order" based on OrderName parameter.Can someone show me how to do this? |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2014-03-26 : 05:09:45
|
[code]CREATE PROCEDURE usp_Update_OrderName @OrderName as varchar(100)ASBEGIN IF NOT Exists(select * from OrderRows where OrderName =@orderName and IsFetched=0) BEGIN UPDATE ORDER SET isFetched=1 WHERE OrderName=@OrderName and IsFetched=0 ENDEND[/code]sabinWeb MCP |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2014-03-26 : 05:13:53
|
Thank you very much! |
|
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2014-03-26 : 05:23:33
|
Your welcome!sabinWeb MCP |
|
|
|
|
|