Blog Archives

SQL Server – Add Column Script

–Add a column to an existing table ALTER TABLE dbo.EmployeeADD Active varchar(1)GO –Add default to new column ALTER TABLE dbo.EmployeeADD CONSTRAINT Employee_Active DEFAULT (‘N’) FOR ActiveGO Advertisements

Tagged with: , , , ,
Posted in Visual Studio Code Examples

SQL Server List Tables And Columns

–List Column Names SELECT COLUMN_NAME, TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG = ‘YOUR_DB_NAME’ –List Tables SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG = ‘YOUR_DB_NAME’ –List Views SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_CATALOG = ‘YOUR_DB_NAME’ –List All Columns in All Views SELECT *

Tagged with: , , , , ,
Posted in SQL Server

SQL Server Add Default To Existing Table

–String Value ALTER TABLE [Table1] ADD CONSTRAINT [Table1_Column1] DEFAULT (‘Not Applicable’) FOR [Column1] GO –Numeric Value ALTER TABLE [Table1] ADD CONSTRAINT [Table1_Column1] DEFAULT ((0)) FOR [Column1] GO –Date Value ALTER TABLE [Table1] ADD CONSTRAINT [Table1_Column1] DEFAULT (((1)/(1))/(1900)) FOR [Column1] GO

Tagged with: , , , , , ,
Posted in SQL Server

HTML Table Example

The example below displays how to create a table using HTML and the <table> tag. The example below consists of the following elements: <table> This tag begins the table. border = “1” This attribute defines the width of the border.

Tagged with: , , , , , , , ,
Posted in HTML Examples

Create a Table From a SQL Statement

You can create a copy of a table using the SELECT INTO command. SELECT * INTO TABLE2 FROM TABLE1 You can also join two or more tables and create a new table from the joined tables. SELECT * INTO TABLE3

Tagged with: , , , , , ,
Posted in SQL Server

SQL Server DatePart Example

select datepart(quarter,getdate()) –Get Week Day Numerical value, Sunday = 1st day of week SELECT   CASE WHEN datepart(weekday,getdate()) = 1 THEN ‘Sunday’ WHEN datepart(weekday,getdate()) = 2 THEN ‘Monday’ WHEN datepart(weekday,getdate()) = 3 THEN ‘Tuesday’ WHEN datepart(weekday,getdate()) = 4 THEN ‘Wednesday’

Tagged with: , , , ,
Posted in SQL Server

Facebook Tip – View Photos The ‘Old’ Way (Without the Pop Up)

Facebook recently changed the way you view photos.  By default, when you click on a photo, the photo pop ups over the Facebook page.  Previously, when you clicked on a photo, you would be directed to another Facebook page with

Tagged with: , , , ,
Posted in Facebook Tips