krypted.com

Tiny Deathstars of Foulness

SQL constraints the data that can be in a table. A violation of a constraint causes an action to be aborted. Constraints can be defined upon creation or using the ALTER TABLE statement once created. The general syntax of a CREATE (or use ALTER instead of CREATE) when defining constraints is as follows:

CREATE TABLE tablename
(
columnname datatype(size) constraintname,
columnname datatype(size) constraintname,
columnname datatype(size) constraintname,
columnname datatype(size) constraint name,
columnname datatype(size) constraint name,
);

Obviously, replace columnname with the name of each of your column, datatype with the types of data your column contains and constraint name with the constraint you wish to use. You have the following constraints available:

  • CHECK: Verify that values meet the defined condition
  • DEFAULT: Sets a default value for new rows in a column
  • FOREIGN KEY: Verify referential integrity of data in a table to match values in another
  • NOT NULL – Columns cannot store a NULL value (be empty)
  • PRIMARY KEY – Columns cannot store a NULL value AND values in rows must be unique
  • UNIQUE – Each row in a column must be unique

For example, the NOT NULL constraint would be defined as follows:

CREATE TABLE testingnotnull
(
telephonenumber int NOT NULL,
);

If you have an app sitting in front of a database, then use these with caution, as if SQL just terminates an operation your app might have unexpected integrity issues.

February 21st, 2016

Posted In: SQL

Tags: , , , , , , , , ,

There are a lot of environments that standardize mail signatures. In Exchange 2010 you can now automatically assign users a signature based on a user’s Active Directory information, thus allowing en masse standardization of signatures. To do so is pretty straight forward, first open the Exchange Management Console and browse to the Organization Configuration. Then click on Hub Transport and then on Transport Rules. Next, click New to create a new transport rule. Here you can build an organizational signature based on user’s Active Directory attributes.

You can provide some text and then any of the attributes that you see fit by wrapping them in the standard double percentage signs (%%). In the following, we provide displayName, Title and Department:

Thank you,<br>

%%displayName%% %%Title%%<br>

 

%%Department%%

Or, if display names are not correctly formatted (in some organizations they aren’t), you can use first name followed by last name and then a line with the email address (%%mail%%):

Thank you,<br>

%%givenName%% %%sn%%<br>

 

%%mail%%

To see a list of all of the attributes available, use ADSI Edit. You can access ADSI Edit by opening adsiedit.msc (Start > Run > adsiedit.msc). In 2008, ADSI Edit is installed automatically when the Active Directory Domain Services role is installed, so simply run it from any existing domain controller. Once open, browse to the domain and then to CN=Users. From here, you’ll see the attributes defined in the schema.

April 23rd, 2011

Posted In: Microsoft Exchange Server, Windows Server

Tags: , , , , , , , ,