0%

SQL Server存储过程

前面啥也没有

查询赋值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
USE [EOLData]
GO
/****** Object: StoredProcedure [dbo].[UpDateHLAResult] Script Date: 07/12/2020 13:45:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[UpDateHLAResult]
(
@VIN varchar(30),
@ZTS varchar(30),
@LLOffset FLOAT
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @sem varchar(30) = ''''
-- 声明变量
DECLARE @LHB FLOAT
-- 判断是否存在数据
IF EXISTS(select [左远光灯高] from [dbo].[车型配置] where [ZTS]=@ZTS)
BEGIN
-- 查询赋值
select @LHB = [左远光灯高] from [dbo].[车型配置] where [ZTS]=@ZTS
END
ELSE
BEGIN
select @LHB = [左远光灯高] from [dbo].[64字节车型配置] where [ZTS]=@ZTS
END
-- 赋值
SET @LHB = @LHB - @LHOffset
begin
exec(
'UPDATE [dbo].[灯光表] SET '
+'[左远光灯高] = '+@sem+ @LHB +@sem
+'WHERE [VIN] = '+@sem+ @VIN +@sem
)
end
END