Thursday, May 27, 2010

Convert CYYMMDD format to datetime - SQL

Convert CYYMMDD to DateTime,Convert CYYMMDD to DateTime Format,SQL,SQL Query,AS400 datetime
In the date format CYYMMDD(AS400 date format), C is Century.

If C is 0 the year is 19XX, and it is 20XX if C is 1(Where XX can be any
two digit year).

YYMMDD is Year Month and Day(All two digit).

In CYYMMDD format, today's date (May 27, 2010) would be 1100527.

It is '0' for 19 and '1' for 20 to make our comparisons easy.

But the '0' will not present in the table data as the leading zeroes of numeric will be truncated.

The following query converts the CYYMMDD format to datetime format:

SELECT dbo.TBL.ACTDT  AS ActualDate, CAST(CASE WHEN SUBSTRING(RIGHT('00' + CAST(dbo.TBL.ACTDT AS VARCHAR), 7), 1, 1) = '0' THEN '19' ELSE '20' END + SUBSTRING(RIGHT('00' + CAST(dbo.TBL.ACTDT AS VARCHAR), 7), 2, 2) + SUBSTRING(RIGHT('00' + CAST(dbo.TBL.ACTDT AS VARCHAR), 7), 4, 4) AS DATETIME) AS [Converted Date] FROM TBL


Query Result:

Convert CYYMMDD Format to datetime format

Invalid object name 'INFORMATION_SCHEMA.tables' - SQL Error

Invalid object name 'INFORMATION_SCHEMA.tables',SQL Errors and Solutions,SQL

The error Invalid object name 'INFORMATION_SCHEMA.tables' was thrown when I executed the  following query,

Select * from INFORMATION_SCHEMA.tables

for a particular database.

Reason: The particular database was case sensitive.

Solution:
I re-ran the same query with upper-case letters and it worked fine.

Select * from INFORMATION_SCHEMA.TABLES - did the trick for me.

Google Chrome browser keyboard shortcuts

Ctrl-Alt-Del in Remote Desktop Connection Window,Remote Machine, Keyboard Shortcuts
Google Chrome offers some tips on keyboard shortcut for easy navigation and operation. The below keyboard hotkeys or accelerators are the lists of common and useful built-in shortcuts .

CTRL + SHIFT + N : automatically opens up a Chrome ‘incognito’ window which allows you to surf on a PC without leaving behind any digital footprints.

SHIFT + Escape: allows for fast access to Chrome’s task Manager utility that allows you to nix browser processes that have gone awry.

CTRL + SHIFT + T: will open recently closed browser tabs.

Window And Tab Shortcuts:

Ctrl+N – Open a new window

Ctrl+Shift+N – Open a new window in incognito mode

Press Ctrl,and click a link – Open link in a new tab

Press Shift, and click a link – Open link in a new window

Alt+F4 - Close current window

Ctrl+T - Open a new tab

Ctrl+Shift+T – Reopen the last tab you’ve closed. Google Chrome remembers the last 10 tabs you’ve closed.

Drag link to tab – Open link in specified tab

Drag link to space between tabs – Open link in a new tab in the specified position on the tab strip

Ctrl+1 through Ctrl+8 – Switch to the tab at the specified position number. The number you press represents a position on the tab strip.

Ctrl+9 – Switch to the last tab

Ctrl+Tab or Ctrl+PgDown – Switch to the next tab

Ctrl+Shift+Tab or Ctrl+PgUp – Switch to the previous tab

Ctrl+W or Ctrl+F4 – Close current tab or pop-up

Alt+Home – Open your homepage

Ctrl+O, then select file – Open a file from your computer in Google Chrome


Shortcuts To Open Google Chrome Features:

Ctrl+B – Toggle bookmarks bar on and off

Ctrl+H – View the History page

Ctrl+J – View the Downloads page

Shift+Escape – View the Task manager

Webpage Shortcuts:

Ctrl+P – Print your current page

F5 – Reload current page

Esc – Stop page loading

Ctrl+F5 or Shift+F5 – Reload current page, ignoring cached content

Press Alt, and click a link – Download link

Ctrl+F – Open find-in-page box

Ctrl+G or F3 – Find next match for your input in the find-in-page box

Ctrl+Shift+G or Shift+F3 – Find previous match for your input in the find-in-page box

Ctrl+U – View source

Drag link to bookmarks bar – Bookmark the link

Ctrl+D – Bookmark your current webpage

Ctrl++ – Make text larger

Ctrl+- – Make text smaller

Ctrl+0 – Return to normal text size

Text shortcuts:

Highlight content, then press Ctrl+C – Copy content to the clipboard

Place your cursor in a text field, then press Ctrl+V or Shift+Insert – Paste current content from the clipboard

Place your cursor in a text field, then press Ctrl+Shift+V – Paste current content from the clipboard without formatting

Highlight content in a text field, then press Ctrl+X or Shift+Delete – Delete the content and copy it to the clipboard

Ctrl-Alt-Del in Remote Desktop Connection Window

Ctrl-Alt-Del in Remote Desktop Connection Window,Remote Machine, Keyboard Shortcuts

Ctrl-Alt-Del keyboard shortcut has been commonly used since IBM PC with DOS era to perform soft reboot, and used in modern Windows system to activate Winlogon process (log on to Windows NT), open Task Manager or Windows Security dialog box that allows user to log off, lock computer, shutdown PC, run Task Manager, switch user and other functions.

However, whenever trying to trigger Ctrl-Alt-Del function on remote system connected via Remote Desktop Connection, the keyboard shortcut combination pressed will bring up the Ctrl+Alt-Del function on the local machine instead of the machine remotely logged on via RDC.

This behavior is by design though, as Ctrl-Alt-Del key combination is too important for any PC (to run especially when computer encounters halt error or hang). As such, Ctrl-Alt-Del keyboard shortcut is always reserved for local host computer.

In order to send Ctrl-Alt-Del keystrokes to remote computer connected via Remote Desktop client, just press the following Key combination:

Ctrl+Alt+End

a work around keyboard shortcut specially for Remote desktop machine.

Thursday, May 6, 2010

Not enough storage is available to process this command

Not enough storage is available to process this command
I recently faced an issue in the development server, the error message "Not enough storage is available to process this command" popped up when try to ran the longer query in the sql server.


Not enough storage is available
Not enough storage is available to process this command





The reason for the error was due to the  IPRStackSize registry entry was missing or setting too low.

In my case the IPRStackSize registry entry was missing .

To resolve these errors I did the following:

1) Start -> Run ->Type regedit
2) Locate and click the following entry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters

3)If the IRPStackSize entry is not present in this subkey, follow these steps:


   Click Edit, point to New, and then click DWORD Value.

   Type IRPStackSize, and then press ENTER.

   Note: Type IRPStackSize exactly as it appears. The value name is case sensitive.

4) Right Click IRPStackSize and then click Modify.

IPRStackSize


5) Select the Base as decimal. In the Data Value box, type a larger value and then click OK.

Edit IPRStackSize

Wednesday, May 5, 2010

Convert YYYYMMDD to DateTime SQL

Convert YYYYMMDD to DateTime,Convert YYYYMMDD to DateTime Format,SQL,SQL Query
The following SQL query converts the date stored as decimal or numeric in the form of YYYYMMDD to datetime.


1) SELECT CAST(CAST(YourDateField AS VARCHAR(8)) AS DATETIME)


For example:

SELECT CAST(CAST(20060204 AS VARCHAR(8)) AS DATETIME) AS [DateTime]


will be displayed as

2006-02-04 00:00:00.000

2) CONVERT(datetime, YourDateField) AS [DateTime]

     For example:


   CONVERT(datetime, '20060204') AS [DateTime]

   will be displayed as

     02/04/2006






Monday, May 3, 2010

WPF application executable path

In windows forms, Application.ExecutablePath gives the executable path of the application.

What is the alternative in WPF?



System.Reflection.Assembly.GetExecutingAssembly().Location will give the executable path of the WPF application.

Convert Julian Date YYYYDDD to Datetime Format

Convert YYYYDDD to datetime,Convert Julian Date YYYYDDD to Datetime Format,Convert Julian Date YYYYDDD to Gregarian Format,SQL,SQL Query
I got a requirement to display the date which is the format 7-digit YYYYDDD (Julian Date) to display in Gregarian format.

This is the query I wrote to convert YYYYDDD format to YYYY-MM-DD format.

YYYY - 4 - digit Year
DDD -  number of the day in the year

SQL Query:

SELECT  [Julian Date], DATEADD(DAY, [Julian Date]% 1000 - 1, DATEADD(YEAR,


[Julian Date]/ 1000 - 1900, 0)) AS [Gregarian Date]


FROM dbo.Test
 
Sample Output: