将SpareDate字段设置为服务器日期IF库存小于5。 [英] Set a SpareDate Field to Server Date IF Stock is less than 5.

查看:56
本文介绍了将SpareDate字段设置为服务器日期IF库存小于5。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想知道你是否可以帮我一把..我正在尝试写一些SQL我会跑aa将扫描StockItem表并使用服务器日期更新SpareDate字段的作业如果库存数量低于5.



我认为我沿着正确的线但是如果可能的话,我想检查你所有的SQL Guru :)



Hi Guys,

I was wondering if you could give me a hand here please.. I'm trying to write a bit of SQL Which I will run a a Job that will scan the StockItem table and Update a SpareDate field with the Server Date IF the Stock Quantity is under 5.

I think I am along the correct lines but wanted to check you all the SQL Guru's out there if possible :)

DECLARE @Date DATE
SET @Date = GETDATE()

UPDATE Sage200DemoData.dbo.StockItem
SET SpareDate3 =
CASE
WHEN FreeStockQuantity <= '5' THEN SpareDate3 = @Date
END





但是我想我的'='符号附近有错误的语法。



任何指针都会很棒! :)非常感谢。



However I think I have the wrong syntax near the '=' sign.

Any pointers would be great! :) Many thanks.

推荐答案

UPDATE Sage200DemoData.dbo.StockItem
SET SpareDate3 = @Date
WHERE FreeStockQuantity <= 5


这篇关于将SpareDate字段设置为服务器日期IF库存小于5。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆