| |

VerySource

 Forgot password?
 Register
Search
View: 1850|Reply: 12

sql server failed to find the stored procedure

[Copy link]

3

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2021-3-5 10:30:02
| Show all posts |Read mode
My stored procedure is like this
CREATE PROCEDURE GetCardByNumber
@CardNumber nvarchar(255)
AS
DECLARE @sql NVARCHAR(2000)

   set @CardNumber ='''' + replace(@CardNumber,'.',''',''') +''''

SET @sql ='select * from CardTable where CardNumber in ('+ @CardNumber +')'
exec @sql
GO

When I run it, I get an error: Cannot find the stored procedure'select * from CardTable where CardNumber in ('226026275526')'.

Please help analyze the error. Thank you
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2021-3-5 10:45:01
| Show all posts
226026275526--Do you know what this is?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2021-3-5 11:00:01
| Show all posts
exec @sql

====>
exec (@sql)
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 United States

Post time: 2021-3-5 11:15:01
| Show all posts
set @CardNumber =replace(@CardNumber,'.',',')
SET @sql ='select * from CardTable where CardNumber in (‘’' + @CardNumber +'‘’)'
exec @sql
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2021-3-5 11:30:02
| Show all posts
I'm wrong, sorry
Reply

Use magic Report

3

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2021-3-5 11:45:01
| Show all posts
set @CardNumber =replace(@CardNumber,'.',',')
SET @sql ='select * from CardTable where CardNumber in (‘’' + @CardNumber +'‘’)'
exec @sql

Still not working, unable to find the stored procedure'select * from CardTable where CardNumber in (''888574781435'')'.
Reply

Use magic Report

3

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2021-3-5 12:00:01
| Show all posts
exec @sql

====>
exec (@sql)
Can you elaborate on what it means, I don’t understand
Reply

Use magic Report

3

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2021-3-5 12:15:01
| Show all posts
No data can be found after using this exec (@sql)
Reply

Use magic Report

0

Threads

34

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2021-3-5 12:30:02
| Show all posts
You execute the @sql statement, the correct way is exec(@sql)
Reply

Use magic Report

3

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2021-3-5 12:45:01
| Show all posts
My select statement is ok
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