| |

VerySource

 Forgot password?
 Register
Search
Author: 命犯桃花

Novice seeking a SQL stored procedure (online, etc ...)

[Copy link]

3

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-4-10 01:00:02
| Show all posts
Server: Message 286, level 16, state 1, procedure auto_update, line 4
The logical tables INSERTED and DELETED cannot be updated.
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-4-10 20:00:02
| Show all posts
create table temp (ID int, product ID int, time datetime, v1 int, v2 int, v3 int, v4 int, sums int)




create trigger auto_update on temp
for insert
as
   update a set a. time = getdate (), a.sums = a.v1 + a.v2 + a.v3 + a.v4 from temp a, inserted b where a. product ID = b. product ID


insert temp (Product ID) values ​​(2001)

select * from temp
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-4-11 19:15:01
| Show all posts
create table Tt (
id int identity,
Product ID varchar (10),
Time char (5) default convert (char (5), getdate (), 108),
v1 int default 1,
v2 int default 1,
v3 int default 1,
v4 int default 1,
sums int default 4
 )
Reply

Use magic Report

3

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-4-12 11:15:01
| Show all posts
Thank you, the problem has been solved
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list