Friday, 31 January 2020

Display 12 months name from sql server


////////// Query

SELECT MONTH(DATEADD(MM, s.number, CONVERT(DATETIME, 0))) [ID], LEFT(DATENAME(MONTH, DATEADD(MM, s.number, CONVERT(DATETIME, 0))),3) [Value] 
FROM master.dbo.spt_values s WHERE [type] = 'P' AND s.number BETWEEN 0 AND 11 ORDER BY 1


////////////// Result


ID
Value
1
Jan
2
Feb
3
Mar
4
Apr
5
May
6
Jun
7
Jul
8
Aug
9
Sep
10
Oct
11
Nov
12
Dec


SELECT MONTH(DATEADD(MM, s.number, CONVERT(DATETIME, 0))) [ID], DATENAME(MONTH, DATEADD(MM, s.number, CONVERT(DATETIME, 0)))[Value]

FROM master.dbo.spt_values s WHERE [type] = 'P' AND s.number BETWEEN 0 AND 11 ORDER BY 1

//////////////  Result

ID
Value
1
January
2
February
3
March
4
April
5
May
6
June
7
July
8
August
9
September
10
October
11
November
12
December

Monday, 27 January 2020

Allow cross origin in leaflet (Access-Control-Allow-Origin)

Step 1.

Copy the zar file at the location-
C:\Program Files (x86)\GeoServer 2.12.1\webapps\geoserver\WEB-INF\lib


Step 2. 
Modify the web.xml file at the locaiton- 
C:\Program Files (x86)\GeoServer 2.12.1\webapps\geoserver\WEB-INF


   <!-- Uncomment following filter to enable CORS -->
   <!--<filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
    </filter>
  -->
To
   <!-- Uncomment following filter to enable CORS -->
   <!-- -->
   <filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
    </filter>




and

<!-- Uncomment following filter to enable CORS -->
    <!--<filter-mapping>
        <filter-name>cross-origin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
     -->
To

  <!-- Uncomment following filter to enable CORS -->
    <!--  -->
  <filter-mapping>
        <filter-name>cross-origin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping> 

Step 3. Restart the geoserver.

Sunday, 5 January 2020

Count total number of char and their type in a string using sql server

//////////////// Sql String


declare @str varchar(max)='this is a test string', @tlen int=0,@lstStr varchar(max)='',@fStr varchar(max)='',@Fchar varchar(10)=''

set @tlen=len(@str)
while @tlen>0
begin
set @Fchar=left(@str,1)
set @fStr=@fStr+'Total Count of '''+@Fchar+''' :  '+cast(len(@str)-len(replace(@str,@Fchar,'')) as varchar)+', '
set @str=replace(@str,@Fchar,'')
set @tlen=len(@str)
end

print @fStr



///////////////////// Result

Total Count of 't' :  4, Total Count of 'h' :  1, Total Count of 'i' :  3, Total Count of 's' :  4, Total Count of ' ' :  4, Total Count of 'a' :  1, Total Count of 'e' :  1, Total Count of 'r' :  1, Total Count of 'n' :  1, Total Count of 'g' :  1,


How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...