1#
本帖提供一些实施服务过程中经常使用到的小脚本,虽简单,但是对于SQL不好,或不了解S4软件数据库结构的人,还是有一定帮助的。

1、--查看VIN有重复的:
select VIN_NO from MS_Vehicle group by VIN_NO having count(VIN_NO) > 1

2、--商品来源修改为“其他”:
update MS_Material set ITEM_FORM=3

3、--更新客户档案主档上的隶属部门全部为空:
update MS_Customer set DEPT_ID=null

4、--修改所有维修单 计提工时=工时:
update MS_SVItemDetail set JT_MAN_HOUR=STD_MAN_HOUR,
JT_AMT=STD_HOUR_AMT where isnull (JT_MAN_HOUR,0)=0

5、--修改系统参数SY007=3:
update MS_SysSet set F_VALUE='3.0' where SET_CODE='SY007'

6、--修改开账日期为201009:
update MS_SysSet set S_VALUE='201009' where SET_CODE='GL003'

7、--取消开账日期为201104份的总账开账:
update MS_AcctPeriod set GL_STATUS=0 where YYYYMM='201104'

8、--把商品采购定价更新至索赔价格
update MS_Material set SB_PRICE=LAST_PURCHASE_PRICE where ITEM_TYPE=0

9、--更新表MS_Dataset中description=嘉年华的列为“嘉年华?”
update MS_Dataset set description='嘉年华? ' where description='嘉年华'

10、--查询表MS_Dataset中description列包含“嘉年华”的项
select description from MS_Dataset where description like '%嘉年华%'

11、--查询表MS_Dataset中description列包含“?”的项
select description from MS_Dataset where charindex('?',description)>0

12、--查询表MS_Dataset中Code_ID列编号从10000到40000的项
select Code_ID,description from MS_Dataset where ([Code_ID]between '10000'and'40000')

13、--解决日志文件过大引起的无法登录的问题:
exec MS_ShrinkDB '数据库名称'

14、--查询材料管理费为空的所有维修单,并将其发票类别修改为“内部单据”
select * from MS_SVMaster where isnull(GL_PRE,0)=0 or isnull(GL_AMT,0)=0
update MS_SVMaster set TAX_ID=105 where isnull(GL_PRE,0)=0 or isnull(GL_AMT,0)=0