MayfieldGlobal

Everything from operating systems, programming to web development and more.

Jan
09

How do I concatenate characters or strings using SQL?

Posted under SQL Server 2005, T-SQL

Concatenation (joining 2 or more characters or strings of the same data type) is accomplished using the “+” operator. For example, let’s say that I want to join the strings “Able” and “Baker”. To do so, I would simply write:

SELECT 'Windows' + 'Vista' AS OSName

Running this query would return:
Read the rest of this entry »

Jan
09

How do I select only the date from a datetime data type?

Posted under SQL Server 2005, T-SQL

Selecting only the date portion from a datetime data type could be accomplished in a number of ways. One of the most convenient methods is to simply use CONVERT and one of the many style values.

SELECT GETDATE() AS MyDate

returns the default format:
Read the rest of this entry »

Jan
09

How do I select the name for a day of the week?

Posted under SQL Server 2005, T-SQL

Selecting the name for a day of the week is fairly straight forward using the DATENAME function and a DATEPART argument. For example:

SELECT DATENAME(weekday, GETDATE()) AS 'MyDay';

returns:
Read the rest of this entry »

Jan
08

How do I install the AdventureWorks sample database with SQL Server 2005 Express?

Posted under SQL Server 2005, Windows Vista

File Download:

  1. Navigate to: http://www.codeplex.com/MSFTDBProdSamples.
  2. From the: Releases tab, click: SQL Server 2005 (hyperlink).
  3. Scroll down and click: AdventureWorksLT.msi.
  4. Save the file to your desktop or other known location.
  5. Once the download is complete, click: Run (or navigate to the location where you saved the file and double-click: AdventureWorksLT.msi) to start the install.
  6. Follow the prompts (using the default selections) to complete the install.

Read the rest of this entry »