| |

VerySource

 Forgot password?
 Register
Search
View: 846|Reply: 6

How to write searched stored procedures?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-20 23:30:02
| Show all posts |Read mode
I don't know whether to use dynamic queries with query conditions as parameters or define a parameter for each query condition?
Reply

Use magic Report

0

Threads

35

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-6-26 18:15:01
| Show all posts
Dynamic query uses query conditions as parameters
Reply

Use magic Report

0

Threads

93

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 China

Post time: 2020-6-26 19:30:01
| Show all posts
The landlord is best to look at the online help instructions, and then look at the examples you wrote, which is easier to get started.
Store data and queries that can be used to change tables
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-6-27 09:30:01
| Show all posts
Recommended parameters
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-6-27 11:15:01
| Show all posts
Are there any good examples of LS friends?
I am also suffering from no examples and no experience
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-9 10:45:01
| Show all posts
CREATE PROCEDURE SplitPage
@SQL VARCHAR(400),
@Page int,
@RecsPerPage int,
@ID VARCHAR(255),
@Sort VARCHAR(255),
@where VARCHAR (255)

AS

DECLARE @Str nVARCHAR(4000)

SET @Str='SELECT TOP'+CAST(@RecsPerPage AS VARCHAR(20))+' * FROM'+@SQL+' WHERE'+@where +'and'+@ID+' NOT IN (SELECT TOP'+CAST( (@RecsPerPage*(@Page-1)) AS VARCHAR(20))+''+@ID+' FROM'+@SQL+' where'+@where+' ORDER BY'+@Sort+') ORDER BY'+@Sort
PRINT @Str EXEC sp_ExecuteSql @Str
GO
Reply

Use magic Report

0

Threads

17

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-8-9 12:00:01
| Show all posts
Use query conditions as parameters
create proc showpage
@pagesize int,
@tablename nvarchar(250),
@pagecount int
@strwhere nvachar(4000)
as
begin
'''''where @strwhere
end
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