| |

VerySource

 Forgot password?
 Register
Search
Author: mgs_pexp

Stored procedure receives multiple parameter problems Master invited

[Copy link]

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-28 16:45:01
| Show all posts
SET @sql = 'UPDATE Images SET [Name] = `` Test' 'WHERE ID IN (' + @idStrings + ')'

Where did @idStrings come from? ? ? ? ? ? Wrong?

=================
It is really wrong, it should be @idString
Reply

Use magic Report

1

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-3-29 11:45:01
| Show all posts
pupupu01written OK
The complete error-free stored procedure is as follows:
CREATE PROCEDURE Test
(
@idStringNVARCHAR (1000)-if its value is 1,2,3,4,6,7,8,
)
AS
update usertable set username = 'test' where charindex (',' + rtrim (id) + ',', ',' + @ idString + ',')> 0
GO
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-31 12:30:01
| Show all posts
If you don't want the page to loop, you have to loop through the stored procedure
First combine your id into a string and assign it to the stored procedure as a parameter, then use while while in the stored procedure
+ charindex for loop
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-3-31 21:15:01
| Show all posts
Splitting a string in a stored procedure feels annoying, and it is better to assemble the string in a program.
Reply

Use magic Report

0

Threads

29

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-4-1 03:30:01
| Show all posts
...............
The parameters of the stored procedure are unchanged. The parameters have changed, and the copy must also change. Otherwise it will be the same
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