Skip to content

Instantly share code, notes, and snippets.

@radityopw
Created March 1, 2016 03:59
Show Gist options
  • Save radityopw/15e4362c69d13232d148 to your computer and use it in GitHub Desktop.
Save radityopw/15e4362c69d13232d148 to your computer and use it in GitHub Desktop.
use tempdb
go
-- membuat table dan stored procedure
create table radityo_coba1(kunci varchar(255),value text);
GO
CREATE PROCEDURE dbo.usp_mencoba1 @min_len_middle_name int = 3
as
begin
declare @jml_person int
select @jml_person = count(*) from AdventureWorks2012.Person.Person where len(middleName) >= @min_len_middle_name
insert into radityo_coba1(kunci,value) values ('jumlah person with min len '+cast(@min_len_middle_name as varchar),cast(@jml_person as varchar))
end
go
-- menjalankan stored procedure dan melihat hasilnya
exec usp_mencoba1
exec usp_mencoba1 2
exec usp_mencoba1 5
select * from radityo_coba1
-- menghapus
drop table radityo_coba1
DROP PROCEDURE [dbo].[usp_mencoba1 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment