Sujatha
Sujatha

Reputation: 302

How to test and compare stored procedures in Sql server 2014

I have optimised a stored procedure and created as new one. i want to test the new and old one whether both are pulling same data ie. i wanted to do some automated testing.

Anyone please help on this

Upvotes: 2

Views: 202

Answers (2)

Leal Li
Leal Li

Reputation: 257

I don't quite understand your question,but in sqlserver has Audit&Execution Plan maybe solve auto do tasks,you can try

Upvotes: 1

ahoxha
ahoxha

Reputation: 1938

You can achieve this by using in-memory tables.

Let's say you have a stored procedure named getUsers which will give you the list of all the users. The result set contains the fields: Id, Name,Username. Now you can save the result set returned by this stored procedure in an in-memory table, do the same for another stored procedure in an another in-memory table and then compare these two tables.

How can I save the result set of a stored procedure?

Here's how you do it:

declare @MyTable table (Id int, [Name] varchar(50), [Username] varchar(50));

insert into @MyTable
exec getUsers

Do the same thing for the other stored procedure, then compare the result sets returned.

Upvotes: 2

Related Questions