DATEADD This function adds a specified number value (as a signed integer) to a specified datepart of an input date value, and then returns that modified value. The DATEADD function simply allows you to add or subtract the specified number of units of time to a specified date/time value. Syntax DATEADD (datepart , number , date) Arguments datepart - The part of date to which DATEADD adds an integer number. This table lists all valid datepart arguments. datepart - Abbreviations year - yy, yyyy quarter - qq, q month - mm, m dayofyear - dy, y day - dd, d week - wk, ww weekday - dw, w hour - hh minute - mi, n second - ss, s millisecond - ms microsecond - mcs nanosecond - ns number - An expression that can resolve to an int that DATEADD adds to a datepart of date. DATEADD accepts user-defined variable values for number. DATEADD will truncate a specified number value that has a decimal fraction. It will not round the number value in this situation. date - An expression that can resolve t...
Summary: From this post you will learn how to use CURSOR statement in SQL. What is Database CURSOR: A SQL Server cursor is a set of T-SQL logic to loop over a predetermined number of rows one at a time. The purpose for the cursor may be to update one row at a time or perform an administrative process such as SQL Server database backups in a sequential manner. SQL Server cursors are used for Development, DBA and ETL processes. Why Use a Cursor in SQL Server: Although using an INSERT , UPDATE or DELETE statement to modify all of the applicable data in one transaction is generally the best way to work with data in SQL Server, a cursor may be needed for: Iterating over data one row at a time. Completing a process in a serial manner such as SQL Server database backups. Updating data across numerous tables for a specific account. Correcting data with a predefined set of data as the input to the cursor. When to Use a SQL Server Cursor: The ...