tag:blogger.com,1999:blog-6082652835152798567.post4329102187424338572..comments2024-03-28T00:58:12.736-07:00Comments on Sql server, .net and c# video tutorial: Stored procedures with output parameters - Part 19Unknownnoreply@blogger.comBlogger10125tag:blogger.com,1999:blog-6082652835152798567.post-33169023684511426462021-06-22T07:22:31.922-07:002021-06-22T07:22:31.922-07:00hi bro
Declare @gender nvarchar(20),@TotalCount in...hi bro<br />Declare @gender nvarchar(20),@TotalCount int<br />Execute proc_GetEmployeesCount 'Male',@TotalCount out<br />Print @ToltalCountmaddyhttps://www.blogger.com/profile/04106120011590330493noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-66729207654842647842021-01-27T22:17:53.963-08:002021-01-27T22:17:53.963-08:00I think he is Totla. I think he is Totla. Ashish Kumarhttps://www.blogger.com/profile/13777479959881286004noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-34278577453975949002020-04-13T06:52:43.724-07:002020-04-13T06:52:43.724-07:00While creating the store procedure we are not usin...While creating the store procedure we are not using declare keyword to declare the variable like @gender and @employee code. But @the time executing the sp we are using declare keyword. why, please explain??Anonymoushttps://www.blogger.com/profile/14555658557082026416noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-13407754040191353602019-06-09T18:40:58.982-07:002019-06-09T18:40:58.982-07:00Declare @TotalCount int
Execute proc_GetEmployeesC...Declare @TotalCount int<br />Execute proc_GetEmployeesCount <br />@empCount = @TotalCount <br />OUT , @empGender = 'Male'<br /><br />Print @ToltalCount <<<<<<<<totalcount is writen as toltalAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-78719902503261143832019-05-05T19:25:36.814-07:002019-05-05T19:25:36.814-07:00Hi bro,
please check the declare variable name and...Hi bro,<br />please check the declare variable name and print variable name.Anonymoushttps://www.blogger.com/profile/01314809053217219592noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-91471752756413239682018-09-10T03:17:46.204-07:002018-09-10T03:17:46.204-07:00You are simple awesome man.. Bundle of ThanksYou are simple awesome man.. Bundle of ThanksAnonymoushttps://www.blogger.com/profile/08749880184148868606noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-23719123581633036982017-03-06T18:52:25.153-08:002017-03-06T18:52:25.153-08:00Anyone knows who to create a procedure where the t...Anyone knows who to create a procedure where the table name is also a parameter.<br /> I wrote a small procedure but could find a way to print the results yet.<br /><br />-- Create a procedure where th etable name is a parameter<br />Create Procedure spGetEmployeeCountByGender2<br />@TableName nvarchar(20) OUTPUT<br />As<br />Begin<br /><br />SET NOCOUNT ON;<br /> DECLARE @Sql NVARCHAR(MAX);<br /><br />SET @Sql = N'SELECT TOP 10 * INTO #Temp_Table_One <br /> FROM ' + QUOTENAME(@TableName)<br /> + N' SELECT * FROM #TableName '<br /><br /> End<br /><br /> DECLARE @Sql NVARCHAR(MAX)<br /> DECLARE @MyOutput NVARCHAR(MAX)<br /> Execute spGetEmployeeCountByGender2 @TableName = tblEmployee<br /> Select @MyOutput = @Sql<br /><br />Here is the code to create the table:<br /><br /> Create table tblEmployee<br />(<br /> ID int primary key,<br /> Name nvarchar(50),<br /> Gender nvarchar(50),<br /> Salary int,<br /> DepartmentId int foreign key references tblDepartment(Id)<br />)<br />Go<br /><br />Insert into tblEmployee values (1, 'Tom', 'Male', 4000, 1)<br />Insert into tblEmployee values (2, 'Pam', 'Female', 3000, 3)<br />Insert into tblEmployee values (3, 'John', 'Male', 3500, 1)<br />Insert into tblEmployee values (4, 'Sam', 'Male', 4500, 2)<br />Insert into tblEmployee values (5, 'Todd', 'Male', 2800, 2)<br />Insert into tblEmployee values (6, 'Ben', 'Male', 7000, 1)<br />Insert into tblEmployee values (7, 'Sara', 'Female', 4800, 3)<br />Insert into tblEmployee values (8, 'Valarie', 'Female', 5500, 1)<br />Insert into tblEmployee values (9, 'James', 'Male', 6500, NULL)<br />Insert into tblEmployee values (10, 'Russell', 'Male', 8800, NULL)<br />Go <br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-48953974188674267932017-01-03T03:21:04.152-08:002017-01-03T03:21:04.152-08:00YOU CREATE STORE PROCEDURE IS CORRECT BUT IN DECLA...YOU CREATE STORE PROCEDURE IS CORRECT BUT IN DECLARE SECTION WRITTEN SOMETHING WRONG............<br /> CREATE PROCEDURE proc_GetEmployeesCount<br />@EmpGender nvarchar(20),<br />@EmpCount int OUTPUT<br />AS<br />Begin<br />SELECT @EmpCount = COUNT(ID) FROM tblEmployee WHERE Gender = @EmpGender<br />END<br />This is correct.........now type<br /><br />declare @totalcount int<br />excute proc_GetEmployeesCount 'male/female(what u want)',@totalcount output<br />print @totalcountAnonymoushttps://www.blogger.com/profile/00118796006437284519noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-55221040038610403692017-01-03T00:33:01.543-08:002017-01-03T00:33:01.543-08:00Hello bro,
When you call Print, you write wrong n...Hello bro, <br />When you call Print, you write wrong name of the OUTPUT, so the SP can't executeAnonymoushttps://www.blogger.com/profile/00369345703898287823noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-23368357473242078842017-01-02T09:45:56.283-08:002017-01-02T09:45:56.283-08:00Hi
thank u for this tutorial
but I get an error ...Hi <br />thank u for this tutorial <br />but I get an error (Must declare the scalar variable "@ToltalCount".) when I execute my query<br />here's the query:<br /><br />CREATE PROCEDURE proc_GetEmployeesCount<br />@EmpGender nvarchar(20),<br />@EmpCount int OUTPUT<br />AS<br />Begin<br />SELECT @EmpCount = COUNT(ID) FROM tblEmployee WHERE Gender = @EmpGender<br />END<br /><br />Declare @TotalCount int<br />Execute proc_GetEmployeesCount @empCount = @TotalCount OUT , @empGender = 'Male'<br />Print @ToltalCount<br />Anonymousnoreply@blogger.com