SSMS2012: Doing Non-Parameterized & Parameterized Stored Procedures-No Results were listed in the left-handed-side of the Messages!!??

HI all,

From http://www.c-sharpcorner.com/, I copied the following code:

-- scStoredProc_1.sql    from c-sharpconner
--  27 August 2015   15.17 PM 

USE hidDB;
GO


-- Creation of emp table:
create table emp(empId int, empName varchar(15), empAge int )

-- Inserting values
insert into emp 
select 1,'deepak',21 union all
select 2,'Arora',21 union all
select 3,'Vandna',22


--Creation of emp1 table
create table emp1(empId int,empAdd varchar(35)) 
 
--Inserting the value
insert into emp1 
select 1,'delhi'union all
select 2,'banglore'union all
select 3,'usa'

-- getting output
select * from emp1 


--Non-parameterized Stored Procedure for Showing All Records
create proc usp_select
as 
select * from emp 
-- getting output
exec usp_select



--Non-parameterized Stored Procedure for Join:
create proc usp_join
as
select e.empId,e.empName,e.empAge,e1.empAdd from emp e inner join emp1 e1 on e.empId=e1.empId
-- getting output
exec usp_join


--////  Parameterized Stored Procedure for Insert  ////
create proc usp_insert(@id int,@name  varchar(15),@age int)
as
insert into emp values(@id,@name,@age)
--///   getting output   ////
exec usp_insert 4,'Ankit',19 
exec usp_select


--///  Parameterized Stored Procedure for Update   ////
create proc usp_update(@id int,@name  varchar(15),@age int)
as
update emp set empName=@name,empAge=@age where empId=@id
--///  getting output  ///
exec usp_update 4,'Mohan',20
exec usp_select


--\\\\\\ Parameterized Store Procedure for delete  \\\\\\
create proc usp_delete(@id int)
as
delete from emp where empId=@id
--\\\  getting output   \\\\\
exec usp_delete 4
exec usp_select
 

I executed the code in my Microsoft SQL Server 2012 Management Studio (SSMS2012). It worked and Messages said:  Command(s) completed successfully. But, I did not get the output of the Non-Parameterized and Parameterized Stored Procedures listed in the left-handed-side of the Messages!!??  I don't know why and how to fix them.  Please kindly help, advise and respond.

Thanks in advance,

Scott Chang


August 27th, 2015 4:21pm

Check all stored procedure code and remove the exec code inside the stored procedures.
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2015 4:59pm

You need to separate these codes into different batches with a GO between them.
August 27th, 2015 5:02pm

Jingyang points out, there are no "go" separators. However, if you were to execute all that in a single run, you would get plenty of errors telling you that CREATE PROCEDURE must be alone in a batch.

But of the procedures only usp_select and usp_join will produce any output. The others only perform updates.

Free Windows Admin Tool Kit Click here and download it now
August 27th, 2015 6:11pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics