Wednesday, April 4, 2018

Get all week based on month and year using SQL Server


Get all week based on month and year using SQL Server:
DECLARE @Year char(4), @iValue TINYINT, @Month tinyint
--//Populate your parameter values
 SET @Year = '2018';

select * into #temptest from (

SELECT DATEPART(wk,DATEADD(wk,t2.number,@Year)) as Weeknumb,( SELECT DATENAME(month, DATEADD(month,  month(DATEADD(wk,t2.number,@Year + '/01/01')), -1 ))) AS Month
FROM master..spt_values t2
WHERE t2.type = 'P'
AND t2.number <= 255
AND YEAR(DATEADD(wk,t2.number,@Year))=@Year) as T


select 'Week-' + convert(varchar(50), ROW_NUMBER() OVER( ORDER BY Weeknumb)) as Week, 
Weeknumb,Month  from #temptest where Month='April'


Get all week number by given year using SQL Server

Get all week number by given year using SQL Server


DECLARE @Year char(4), @iValue TINYINT, @Month tinyint

--//Populate your parameter values

 SET @Year = '2018';

SELECT DATEPART(wk,DATEADD(wk,t2.number,@Year)) as Weeknumb,( SELECT DATENAME(month, DATEADD(month,  month(DATEADD(wk,t2.number,@Year + '/01/01')), -1 ))) AS Month

FROM master..spt_values t2

WHERE t2.type = 'P'

AND t2.number <= 255

AND YEAR(DATEADD(wk,t2.number,@Year))=@Year

Couldn’t import a Custom Control Default Config for ObjectTypeCode 10022 because its 'customcontroldefaultconfigid' already exists on the system.

Couldn’t import a Custom Control Default Config for ObjectTypeCode 10022 because its 'customcontroldefaultconfigid' already exists on the system.

Solution:

Solution:1

  • Extract the solution file and open the customization.xml file 
  • Remove the content/subnode tag in the "CustomControlDefaultConfigs" node <CustomControlDefaultConfigs> </CustomControlDefaultConfigs>
  • save the file and zip it and import again in the CRM.
Solution:2

  • Use the script below to find the oldest duplicated records on CustomControlDefaultConfigBase
select PrimaryEntityTypeCode, min(CreatedOn) oldest from CustomControlDefaultConfigBase
where PrimaryEntityTypeCode in (select PrimaryEntityTypeCode from CustomControlDefaultConfigBase group by PrimaryEntityTypeCode having count(1) >1) group by
PrimaryEntityTypeCode

  • Delete these records and export the solution again (managed or unmanaged)
  • Try to import it on the new environment