SQL Server Information and Resources Bookmark this page

SQLINFO.net is a Community Service from DataExpressions makers of dbOrchestra©

Google
 

 

 

 


SQL Server Examples

SQL DML

String Functions

Stored Procedures

SQL Views

SQL Table Basics


Misc SQL Server SELECT Examples

SELECT - All columns

Return all columns.

SELECT 
   *  
FROM Courses

SELECT - Return first 10 rows

Run a SQL Select statement and limit the number of rows returned. Useful when you are not sure of how to limit the recordset to be returned and you only want to return a few rows to do some initial analysis.

SELECT TOP 10
  course_designater , 
  course_name       , 
  employee_inactivating 
FROM Courses  

SELECT - Count rows in table

Returns a count of the total number of rows in a table.

SELECT COUNT(*) from Courses

SELECT - Joining tables

Join two SQL Server tables together.

SELECT 
  a.[course_name]      , 
  b.[class_start_date] ,
  b.[class_end_date] 

FROM [dbo].[Courses]  a 
JOIN [dbo].[Classes]  b 
     ON a.[course_designater] = b.[course_designater_fk]

WHERE a.[course_name] LIKE '%Perl%'

 

 



Copyright 2006-2007 by DataExpressions --- All Rights Reserved            dbOrchestra - SQL Server home page