Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-04-11 : 09:22:21
|
need to create sp which return the resultset in table variable and also no of rows count Create Procedure [dbo].[usp_get_data_count] @deptId int, @count_insert INT OUTPUTdeclare @tablevariable (empid int ,empname varchar(20))select * from dim_employee where deptId = @deptId return @tablevariablereturn @count_insertendTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-11 : 09:29:39
|
[code]Create Procedure [dbo].[usp_get_data_count]@deptId int,@count_insert INT OUTPUTASBEGIN select * from dim_employee where deptId = @deptId SET @count_insert = @@ROWCOUNTendGO--Test ProcedureDECLARE @cnt INTEXEC [dbo].[usp_get_data_count] 20, @cnt OUTSELECT @cnt[/code] |
|
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-04-11 : 09:44:25
|
I have @count_insert, @count_error in my Procedurecould you suggest some other command instead of SET @count_insert = @@ROWCOUNTlike..Create Procedure [dbo].[usp_get_data_count]@deptId int,@count_insert INT OUTPUT,@count_delete INT OUTPUT,@count_update INT OUTPUTASBEGIN select * from dim_employee where deptId = @deptId SET @count_insert = @@ROWCOUNTendGO |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-11 : 09:53:29
|
what is the problem with @@ROWCOUNT?--Chandu |
|
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-04-11 : 09:55:19
|
I want to return to .net team mentioning the sp resultsset of insert , update, delete rows and the rows with error records in table variableTHANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-12 : 00:51:07
|
Do you have INSERT , UPDATE, DELETE statements in the procedure? --May be this?Create Procedure [dbo].[usp_get_data_count]@deptId int, . -- Other params for insert/update/delete values ..,@count_insert INT OUTPUT,@count_delete INT OUTPUT,@count_update INT OUTPUT@count_error INT OUTPUTASBEGIN BEGIN TRY Your code for INSERT SET @count_insert = @@ROWCOUNT Your code for UPDATE SET @count_update = @@ROWCOUNT Your code for DELETE SET @count_delete = @@ROWCOUNT END TRY BEGIN CATCH SET @Count_Error = @@ERROR END CATCHEND |
|
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-04-12 : 01:22:16
|
Hi Bandi, Thanks.THANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-12 : 01:52:43
|
quote: Originally posted by shanmugaraj Hi Bandi, Thanks.
Did you get the solution?Anyway, welcome--Chandu |
|
|
|
|
|
|
|