CHECK (entered_date >= CURRENT_TIMESTAMP) : CURRENT_TIMESTAMP « Date Functions « SQL Server / T-SQL Tutorial

SQL Server / T-SQL Tutorial
1. Query
2. Insert Delete Update
3. Table
4. Table Join
5. Data Types
6. Set Operations
7. Constraints
8. Subquery
9. Aggregate Functions
10. Date Functions
11. Math Functions
12. String Functions
13. Data Convert Functions
14. Analytical Functions
15. Sequence Indentity
16. View
17. Index
18. Cursor
19. Database
20. Transact SQL
21. Procedure Function
22. Trigger
23. Transaction
24. XML
25. System Functions
26. System Settings
27. System Tables Views
28. User Role
29. CLR
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL Tutorial » Date Functions » CURRENT_TIMESTAMP 
10. 1. 3. CHECK (entered_date >= CURRENT_TIMESTAMP)
6CREATE TABLE employee
7(
8> emp_id         int          NOT NULL PRIMARY KEY
9>                             CHECK (emp_id BETWEEN AND 1000),
10>
11> emp_name       varchar(30)  NOT NULL CONSTRAINT no_nums
12>                             CHECK (emp_name NOT LIKE '%[0-9]%'),
13>
14> mgr_id         int          NOT NULL REFERENCES employee(emp_id),
15>
16> entered_date   datetime     NULL CHECK (entered_date >=
17>                                 CURRENT_TIMESTAMP),
18>
19> entered_by     int          CHECK (entered_by IS NOT NULL),
20>                             CONSTRAINT valid_entered_by CHECK
21>                                 (entered_by = SUSER_ID(NULLAND
22>                                 entered_by <> emp_id),
23>
24> CONSTRAINT valid_mgr CHECK (mgr_id <> emp_id OR emp_id=1),
25>
26> CONSTRAINT end_of_month CHECK (DATEPART(DAY, GETDATE()) 28)
27)
28> GO
1>
2> EXEC sp_helpconstraint employee
3> GO
Object Name



--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
employee




constraint_type                                                                                                                                    constraint_name
                                                                            delete_action update_action status_enabled status_for_replication constraint_keys











-------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------
--------------------------------------------------------------------------- ------------- ------------- -------------- ---------------------- ----------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------
CHECK on column emp_id                                                                                                                             CK__employee__emp_id__5C6D822E
                                                                            (n/a)         (n/a)         Enabled        Is_For_Replication     ([emp_id]>=(0AND [emp_id]<=(1000))











CHECK on column entered_date                                                                                                                       CK__employee__entere__5F49EED9
                                                                            (n/a)         (n/a)         Enabled        Is_For_Replication     ([entered_date]>=getdate())











CHECK on column entered_by                                                                                                                         CK__employee__entere__603E1312
                                                                            (n/a)         (n/a)         Enabled        Is_For_Replication     ([entered_byIS NOT NULL)











CHECK Table Level                                                                                                                                  end_of_month
                                                                            (n/a)         (n/a)         Enabled        Is_For_Replication     (datepart(day,getdate())<(28))











FOREIGN KEY                                                                                                                                        FK__employee__mgr_id__5E55CAA0
                                                                            No Action     No Action     Enabled        Is_For_Replication     mgr_id












                                                                                                                                              REFERENCES master.dbo.employee (emp_id)











CHECK on column emp_name                                                                                                                           no_nums
                                                                            (n/a)         (n/a)         Enabled        Is_For_Replication     (NOT [emp_namelike '%[0-9]%')











PRIMARY KEY (clustered)                                                                                                                            PK__employee__5B795DF5
                                                                            (n/a)         (n/a)         (n/a)          (n/a)                  emp_id











CHECK Table Level                                                                                                                                  valid_entered_by
                                                                            (n/a)         (n/a)         Enabled        Is_For_Replication     ([entered_by]=suser_id(NULLAND [entered_by]<>[emp_id])











CHECK Table Level                                                                                                                                  valid_mgr
                                                                            (n/a)         (n/a)         Enabled        Is_For_Replication     ([mgr_id]<>[emp_idOR [emp_id]=(1))












Table is referenced by foreign key


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
master.dbo.employee: FK__employee__mgr_id__5E55CAA0


1>
2>
3> drop table employee;
4> GO
10. 1. CURRENT_TIMESTAMP
10. 1. 1. select CURRENT_TIMESTAMP
10. 1. 2. SELECT @today = current_timestamp
10. 1. 3. CHECK (entered_date >= CURRENT_TIMESTAMP)
10. 1. 4. datetime DEFAULT CURRENT_TIMESTAMP
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.