Category Archives: Tips & tricks

Databases SQL Server Tips & tricks Transact-SQL

How to get different SQL Server date formats

Below is a list of formats and an example of the output.  The date used for all of these examples is “2006-12-30 00:38:54.840”.

DATE ONLY FORMATS
Format # Query Sample
1 select convert(varchar, getdate(), 1) 12/30/06
2 select convert(varchar, getdate(), 2) 06.12.30
3 select convert(varchar, getdate(), 3) 30/12/06
4 select convert(varchar, getdate(), 4) 30.12.06
5 select convert(varchar, getdate(), 5) 30-12-06
6 select convert(varchar, getdate(), 6) 30 Dec 06
7 select convert(varchar, getdate(), 7) Dec 30, 06
10 select convert(varchar, getdate(), 10) 12-30-06
11 select convert(varchar, getdate(), 11) 06/12/30
12 select convert(varchar, getdate(), 12) 061230
23 select convert(varchar, getdate(), 23) 2006-12-30
101 select convert(varchar, getdate(), 101) 12/30/2006
102 select convert(varchar, getdate(), 102) 2006.12.30
103 select convert(varchar, getdate(), 103) 30/12/2006
104 select convert(varchar, getdate(), 104) 30.12.2006
105 select convert(varchar, getdate(), 105) 30-12-2006
106 select convert(varchar, getdate(), 106) 30 Dec 2006
107 select convert(varchar, getdate(), 107) Dec 30, 2006
110 select convert(varchar, getdate(), 110) 12-30-2006
111 select convert(varchar, getdate(), 111) 2006/12/30
112 select convert(varchar, getdate(), 112) 20061230
TIME ONLY FORMATS
8 select convert(varchar, getdate(), 8) 00:38:54
14 select convert(varchar, getdate(), 14) 00:38:54:840
24 select convert(varchar, getdate(), 24) 00:38:54
108 select convert(varchar, getdate(), 108) 00:38:54
114 select convert(varchar, getdate(), 114) 00:38:54:840
DATE & TIME FORMATS
0 select convert(varchar, getdate(), 0) Dec 12 2006 12:38AM
9 select convert(varchar, getdate(), 9) Dec 30 2006 12:38:54:840AM
13 select convert(varchar, getdate(), 13) 30 Dec 2006 00:38:54:840AM
20 select convert(varchar, getdate(), 20) 2006-12-30 00:38:54
21 select convert(varchar, getdate(), 21) 2006-12-30 00:38:54.840
22 select convert(varchar, getdate(), 22) 12/30/06 12:38:54 AM
25 select convert(varchar, getdate(), 25) 2006-12-30 00:38:54.840
100 select convert(varchar, getdate(), 100) Dec 30 2006 12:38AM
109 select convert(varchar, getdate(), 109) Dec 30 2006 12:38:54:840AM
113 select convert(varchar, getdate(), 113) 30 Dec 2006 00:38:54:840
120 select convert(varchar, getdate(), 120) 2006-12-30 00:38:54
121 select convert(varchar, getdate(), 121) 2006-12-30 00:38:54.840
126 select convert(varchar, getdate(), 126) 2006-12-30T00:38:54.840
127 select convert(varchar, getdate(), 127) 2006-12-30T00:38:54.840
FORMATS WITH ISSUES
130 select convert(varchar, getdate(), 130) 10 ?? ????? 1427 12:38:54:840A
131 select convert(varchar, getdate(), 131) 10/12/1427 12:38:54:840AM

You can also format the date or time without dividing characters, as well as concatenate the date and time string:

Sample statement Output
select replace(convert(varchar, getdate(),101),’/’,”) 12302006
select replace(convert(varchar, getdate(),101),’/’,”) + replace(convert(varchar, getdate(),108),’:’,”) 12302006004426

read more »

Hyper-V Tips & tricks Utils

VMDK to VHDX

Follow steps:

  • Download: http://www.microsoft.com/en-us/download/details.aspx?id=42497
  • Open Powershell as administrator and run Import-Module 'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1'
  • And after ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath
    d:\scratch\vmx\VM-disk1.vmdk -VhdType DynamicHardDisk -VhdFormat vhdx
    -destination c:\vm-disk1

If you counter following error:

ConvertTo-MvmcVirtualHardDisk : The entry 1 is not a supported disk database entry for the descriptor.

In my case it was entry 4

Follow these steps:

  1. download and extract dsfok tools
  2. use dsfo.exe "c:\temp\disk2.vmdk" 512 1024 descriptor1.txt to extract the descriptor
  3. edit the descriptor file in Notepad++: comment the above mentioned line (as I added the extra single character (#) I also deleted one NULL character from the end to keep the file size of 1024 bytes (not sure if this is needed).
  4. use dsfi.exe "c:\temp\disk2.vmdk" 512 1024 descriptor1.txt to inject the descriptor back into the VMDK
  5. repeat these steps for the other disk (my VM has two .vmdk files)
  6. reissue the ConvertTo-MvmcVirtualHardDisk command

 

Source:

https://gist.github.com/rahilwazir/69a750b70348459875cbf40935af02cb

https://stackoverflow.com/questions/37481737/error-when-converting-vmware-virtual-disk-to-hyperv

Related articles:

Yes, you can! Convert VMDK to VHD with these tools

 

Exchange Microsoft Tips & tricks Tutorials Utils

How to prevent internal email spoofing in an Exchange organization

Ensuring email security might be one of the most important and most difficult tasks an administrator must face. Every day, servers process thousands of emails and controlling such a big mail flow is not easy. No wonder hackers focus on this channel when they plan attacks. They use various tricks to make users think that opening a suspicious attachment is a good idea.

One of the tricks they use is email spoofing.

Prevent Internal Spoofing in Exchange organization

What is email spoofing?

Email spoofing is a very popular attack method. The sender modifies message headers so that emails appear as sent from someone else. Hackers use it, for example, to impersonate employees of a company to obtain login credentials, personal data, or other confidential information. Two most common ways to protect your organization from external spoofing attacks are:

  • An SPF record – a list of IP addresses which are authorized to send emails from a domain.
  • DKIM check – an email authentication method. It enables you to sign and verify email messages using public and private keys. The public keys, published in the DNS records are used to verify if the message comes from the original sender. You cannot configure it on the Exchange Server natively – you require a plugin for SMTP gateway.

Both ways give good results when fighting with external spoofing. The problem starts when we come across internal spoofing when one employee tries to impersonate a colleague. It might be a joke, or to achieve some benefits – either way, it can sabotage a company in a number of ways:

  • Cause chaos,
  • Induce material damage,
  • Harm data integrity,
  • Damage the company reputation.

 

 

See Full article in https://www.codetwo.com/admins-blog/how-to-prevent-internal-email-spoofing-in-exchange/

 

Exchange Office365 Tips & tricks

MRS Proxy Error “The connection to the server could not be completed”

Check MRS endpoint user and password.

read more »

Tips & tricks Utils

Lista com compilação de algumas entidades de multibanco úteis:

Lista com compilação de algumas entidades de multibanco

read more »

Exchange Office365 Tips & tricks

Emails between O365 and On-premises do not work

Error message: 451 4.4.0 Primary target IP address responded with: “451 5.7.3 Must issue a STARTTLS commnd first” Office 365 Hybrid

In some scenarios you might need to, in your firewall:   Disable Content Inspection with TLS

 

more about in:

http://www.moh10ly.com/blog/office-365/emails-between-o365-and-on-premises-do-not-work

Tips & tricks Tutorials

Erro 105 (err_name_not_resolved)

Erro 105 é um erro chato que às vezes você encontrar ao usar o Google Chrome. Na realidade, este erro não é um problema com o Chrome, mas é um problema com a sua conexão com a internet e as configurações de DNS. Siga as instruções deste tutorial para corrigir o problema rapidamente.

Detalhes
Erro 105 é um erro de conexão que pode aparecer quando você estiver usando o Google Chrome. Ele pode aparecer a qualquer momento e não é causada por um determinado site. Quando você encontrar erro 105, você também vai ver a seguinte mensagem exibida:
erro 105 (net::err_name_not_resolved): não foi possível determinar o endereço dns do servidor.
Por que erro 105 aparecem no Chrome?

Há várias razões para erro 105 aparecerá. Eles estão todos relacionados com a configuração de sua conexão de internet e como o seu computador acessa a internet. É muito técnico, mas, essencialmente, o problema é causado pela forma como o computador está tentando se conectar à internet. Ele pode ser bloqueada pelo firewall ou pelo seu ‘router’.

Como corrigir o erro 105?

Existem três métodos para a fixação de erro 105. A melhor solução é alterar as configurações do Google Chome, que é bastante fácil de fazer (solução 2). Os outros dois envolvem redefinir algumas das suas conexões de internet e também verificar o seu regras de antivírus/firewall.
Solução 1
Esta solução irá repor o catálogo Winsock de volta para a configuração padrão. É seguro.
1. Abra o aplicativo cmd (prompt de comando),  Basta clicar no botão do Windows, digite cmd, Botão do Windows 7
2. Isto irá abrir uma janela preta Prompt de comando
3. Tipo: netsh winsock reset catalog
4. Pressione a tecla ENTER
5. Tipo: netsh int ip reset reset.log
6. Pressione a tecla ENTER
7. Reinicie o computador

read more »

Tips & tricks Tutorials

Speed comparison between USB 2.0, USB 3.0, SATA and Firewire

The theoretical maximums are as follows:

In bits per second, that is:

  • USB 1.1 = 12 Mbit/s
  • Firefire 400 = 400 Mbit/s
  • USB 2.0 = 480 Mbit/s
  • FireWire 800 = 800 Mbit/s
  • USB 3.0 = 5 Gbit/s
  • USB 3.1 = 10 Gbit/s
  • eSATA = Up to 6 Gbit/s (750 MB/s) right now as it depend on the internal SATA chip.
  • Thunderbolt = 10 Gbit/s × 2 (2 channels)
  • Thunderbolt 2 = 20 Gbit/s
  • Thunderbolt 3 = 40 Gbit/s

In Bytes per second, that is:

  • USB 1.1 = 1.5 MB/s
  • Firefire 400 = 50 MB/s
  • USB 2.0 = 60 MB/s
  • FireWire 800 = 100 MB/s
  • USB 3.0 = 625 MB/s
  • USB 3.1 = 1.21 GB/s
  • eSATA = 750 MB/s
  • Thunderbolt = 1.25 GB/s × 2 (2 channels)
  • Thunderbolt 2 = 2.5 GB/s

However, this does not provide the actual answer. As an example, FireWire 400 is a serial connection. The entire 400 Mbps is available for data transfer. USB 2.0 sends command and control data through the same connection the data uses limiting the 480 Mbps connection to 380 to 400 Mbps. When considering throughput the list looks entirely different.

https://en.wikipedia.org/wiki/List_of_device_bit_rates#Peripheral

Tips & tricks Tutorials

IP Ratings (Ingress Protection)

IP_Code_ProtectionTwo-digit number established by the International Electro Technical Commission, is used to provide an Ingress Protection rating to a piece of electronic equipment or to an enclosure for electronic equipment.

The protection class after EN60529 are indicated by short symbols that consist of the two code letters IP and a code numeral for the amount of the protection.

Example: IP65 (NEMA 4)
The two digits represent different forms of environmental influence:
• The first digit represents protection against ingress of solid objects.
• The second digit represents protection against ingress of liquids.

The larger the value of each digit, the greater the protection. As an example, a product rated IP54 would be better protected against environmental factors than another similar product rated as IP42.

read more »

Tips & tricks Utils

Fix Internet Explorer Printing Blank Pages

I just ran into an issue where three different clients in the same morning reported that Internet Explorer was printing blank pages.  A quick search on Google turned up the following article: http://www.mutterances.com/?p=83.

The problem specifically manifests itself by printing a blank page with a footer (if you haven’t turned them off) displaying the following line: “file:///C:/Users/userprofile/AppData/Local/Temp/Low/randomfilename.htm”.

To fix this issue, you’ll need to bring up a command prompt (but not with elevated permissions) and type the following commands:

mkdir %userprofile%\AppData\Local\Temp\Low
icacls %userprofile%\AppData\Local\Temp\Low /setintegritylevel low

 
UPDATE:
I’ve also found some information from Microsoft’s site to fix the problem.  They even include a Microsoft Fix It utility to fix the problem automatically: http://support.microsoft.com/kb/973479.

12/2/2014 UPDATE:
I recently had a client contact us about this very problem but the challenge was slightly different.  The web application (online credit card processing) was using framesets and IE was attempting to print an empty frameset.  Microsoft suggests turning on Compatibility Mode, however, I suggested:

  • Highlight what you’d like to print
  • Right click the selection
  • Click Print
  • Make sure to select “Selection” in the page range box
  • Click Print

 

Thanks to http://www.datacorps.com/2012/09/28/how-to-fix-internet-explorer-printing-blank-pages/