Skip to content

2014

Sql Print Sequential Numbers

Print List of Sequential Numbers

-- PRINT OUT LIST OF SEQUENTIAL NUMBERS FROM num_from TO num_to. Max set to up to 9999
DECLARE @num_from int, @num_to int
SELECT @num_from = 1000, @num_to = 1200

SELECT *
FROM (
  SELECT SEQ 
  = 1 * X1.N -- singles
  + 10 * X10.N -- tens
  + 100 * X100.N -- hundreds
  + 1000 * X1000.N -- thousands
  FROM (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X1
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X10
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X100
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X1000
) AS X
WHERE SEQ BETWEEN @num_from AND @num_to
ORDER BY 1

SQL Server - Print All Days of the Year

Print all Days of the Current Year

-- PRINT OUT ALL OF THE DAYS IN THIS YEAR
SELECT DOY 
  = DATEADD(DAY, RC, CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-01-01')
FROM (
  SELECT RC = X1.N + 10 * X10.N + 100 * X100.N
  FROM (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X1
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X10
  CROSS JOIN (
    SELECT 0 AS N UNION ALL
    SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
    SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
    SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
  ) AS X100
) AS X
WHERE YEAR(GETDATE()) = YEAR(
  DATEADD(DAY, RC, CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-01-01')
)
ORDER BY 1

Reset NIC (Network Interface Card) and Firewall Settings

Reset Network Card and Firewall settings

Start from elevated prompt

Reset firewall and NIC configuration states with netsh

Export current active policy of Windows Firewall to a specified file.

```dos netsh advfirewall export %temp%\advfirewall.wfw ````

Restore the Windows Firewall with Advanced Security policy to the default policy. In a Group Policy object, this command returns all settings to not configured and deletes all connection security and firewall rules.

```dos netsh advfirewall reset ````

Resets the BranchCache service. Flushes the local cache. Every configuration parameter of BranchCache will be reset to its default value.

```dos netsh branchcache reset ````

Resets TCP/IP and related components to a clean state.

```dos netsh int ipv4 reset %temp%\ipv4_rst.log ````

Resets IPv6 configuration state.

```dos netsh int ipv6 reset %temp%\ipv6_rst.log ````

Resets Winsock Catalog to a clean state. All Winsock Layered Service Providers which were previously installed must be reinstalled. This command does not affect Winsock Name Space Provider entries.

```dos netsh winsock reset catalog ````

Enable / Disable network card (NIC) using netsh

Show network interfaces (interface name to be used to disable / enable network card).

```dos netsh interface show interface ````

Disable network interface by name

```dos netsh interface set interface name="Local Area Connection" admin=disabled ````

Enable network interface by name

```dos netsh interface set interface name="Local Area Connection" admin=enabled ````

Enable / Disable network card interface using WMIC

Get NIC list and index number:

```dos wmic nic get name, index ````

Enable NIC with index number: (eg: 7)

```dos wmic path win32_networkadapter where index=7 call enable ````

Disable NIC with index number: (eg: 7)

```dos wmic path win32_networkadapter where index=7 call disable ````

Enable by name

```dos wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call disable ````

Disable by name

```dos wmic path win32_networkadapter where NetConnectionID="Wireless Network Connection" call enable ````