SQL Server Management Studio - Shortcut for entering Dates?

14,407

Solution 1

This page http://msdn.microsoft.com/en-us/library/ms175917.aspx has the shortcut documentation for the SQL Table Editor.

Under "Results Pane" it specifies the available shortcuts including "Enter null into a cell: CTRL+0". There are no other shortcuts listed that would do what you wish, so I would say you're out of luck with any easy out of the box trick.

Solution 2

Well, you can add GetDate() as the default value of the column.
Then, if you fill in the other fields in a new row, and do nothing in your date field, it will add the current date when saving the new row.

EDIT: Another solution, if you are an AutoHotkey user (or want to be) is to create an application-specific hotkey that inserts the current date.

FormatTime,CurrentDate,,M/d/yyyy
#IfWinActive,Microsoft SQL Server Management Studio
    ^9::SendInput,%CurrentDate%
return

You can add {RIGHT} after %CurrentDate% to automatically move to the next cell.
You can add h:mm or h:mm tt to the first line to include the current time.

Share:
14,407
Randy Minder
Author by

Randy Minder

Azure Data Architect / Business Intelligence / Tabular Modeling / Power BI Significant experience with data architecture (database architecture, data warehouses, data marts), SSIS and Azure Data Factory, Business Intelligence with Power BI. Check out my new course on Udemy titled "The DAX Workshop Part 1". The best way to learn DAX is by working through real-world scenarios. The course is filled with exercises (45) to help you learn how to use DAX. Our careers and hobbies are fun and important. But each of us has a soul which will live forever, after our bodies die. Do you know where you'll spend eternity? Jesus Christ said there is only one way to heaven, and it is through Him. You won't get a second chance after you die.

Updated on June 12, 2022

Comments

  • Randy Minder
    Randy Minder about 2 years

    In SSMS, when editing a row of data in a table, you can press Ctrl+0 to enter a null in the current cell. Is there any shortcut for entering the current date in a cell?

  • Jay
    Jay over 14 years
    ...but if you are still allowing nulls, you have to delete NULL from the column.
  • Randy Minder
    Randy Minder over 14 years
    Thanks - I suspected that was the case.
  • Jay
    Jay over 14 years
    That hotkey is Ctrl+9, but you can make it anything you want. ^ for ctrl, ! for alt, and + for shift. {F1} etc. for function keys.
  • Gerben
    Gerben almost 9 years
    That being the case, the quickest thing to type is the date in YYYY-mm-dd format (the time will be automatically set to 00:00:00).