I am currently working as a Senior Database Professional and have around 18 years of experience in database.
Degree:-
Master Degree in Computer(MCA)
Certification course in Data Science & Machine Learning from Indian Institute of
Technology (IIT), Delhi
Work experience:-
Designing of the database.
Database Optimization.
Writing Complex Stored Procedures,Functions,Triggers etc.
Designing and developing SSIS & DTS packages.
Designing SQL Reports using SSRS.
Database Server Maintenance.
Certification:-
MCTS: DA-100: Analysing Data with Microsoft Power BI
MCTS: DP-300: Administering Relational Databases on Microsoft Azure
Microsoft certified Sql DBA in Sql server 2008 (MCTS).
Microsoft certified BI professional in Sql server 2008 (MCTS).
Oracle certified profession DBA in ORACLE 10g (OCP)
certified profession DBA in ORACLE 9i (OCP)
My other publication
Technical Blog:- Technologies with Vivek Johari
Guest Author and Blogger at sqlservercentral.com
create proc techmixing_8_4_14 @yr as numeric
as
SET NOCOUNT ON;
set datefirst 1 — to set first day as monday
declare @dt as varchar(8);
declare @count as numeric=1
create table #t1 (mn varchar(20)) — Temporary table
while @count <=12
begin
set @dt=convert(varchar(4),@yr ) + isnull(REPLICATE('0',2-len(convert(varchar(2),@count))),'')+convert(varchar(2),@count)+ '01'
set @count=@count+1
if datepart(dw,convert(date,@dt,112 )) >=6
begin
insert into #t1 (mn) select datepart(MM,@dt)
end
end
select * from #t1
go
exec techmixing_8_4_14 2012
To get month name, we can also replace datepart with datename in below statement :
insert into #t1 (mn) select datepart(MM,@dt)
Really Good Answer Bharat.. Keep it up
Just to little modify the Bharat answer by adding "No count off" in the end.
Create proc techmixing_8_4_14 @yr as numeric
as
begin
SET NOCOUNT ON;
set datefirst 1 — to set first day as monday
declare @dt as varchar(8);
declare @count as numeric=1
create table #t1 (mn varchar(20)) — Temporary table
while @count <=12
begin
set @dt=convert(varchar(4),@yr ) + isnull(REPLICATE('0',2-len(convert(varchar(2),@count))),'')+convert(varchar(2),@count)+ '01'
set @count=@count+1
if datepart(dw,convert(date,@dt,112 )) >=6
begin
insert into #t1 (mn) select datename(MM,@dt)
end
end
select * from #t1
set nocount off
end
go
exec techmixing_8_4_14 2012
Declare @Months Varchar(60)
Declare @loop int
SET @loop=1
WHILE @loop<=12
BEGIN
IF(Datename(dw,'2014/'+str(@loop)+'/1') in ('Saturday','Sunday'))
BEGIN
SET @Months=COALESCE(@Months+ ', ', '')+ DateName( month , DateAdd( month , @loop , 0 ) -1)
END
SET @loop=@loop+1
END
Print @Months
… [Trackback]
[…] Info on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Here you can find 17849 more Information to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Here you can find 72975 more Info to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Find More Info here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Here you can find 89944 more Information on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] There you will find 51397 additional Information on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Info on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Info to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More Info here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More Information here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More on on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Info on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Info to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More Info here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Find More Information here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More Information here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] There you will find 43879 additional Information on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Information to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More Information here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Info on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] There you will find 21371 additional Information to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Here you can find 9966 more Info to that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]
… [Trackback]
[…] Read More Information here on that Topic: techmixing.com/2014/04/question-of-week-08042014.html […]