T-SQL Examples – SQL 2012

Just some random T_SQL examples from SQL Server 2012

Enable/Disable Triggers:
An alternate syntax to enable and disable triggers:
disable trigger trgTest on dbo.Table
enable trigger trgTest on dbo.Table

instead of using ALTER TABLE.

Move Objects To A Different Schema:
For example, to move the object testProc from the ‘test’ schema to ‘dbo’:
alter schema dbo transfer test.testProc

Rename A Database:
exec sp_renameDb ‘OldName’, ‘NewName’

Create A Time From Hour, Minute and Second Values
select TimeFromParts(hour, minute, seconds)
Where hour, minute and seconds are integer values

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: