Sybase Transact-SQL: Selecting data based on date manipulation functions

When querying or working with data based on datetime, date, or time values Sybase has a group of Date functions available to help perform arithmetic operations.  These functions include GETDATE, MONTH, YEAR, DATEADD, and DATEDIFF. To help illustrate some of these functions lets assume we have the following ITEM, ORDERS, and ORDERS_ITEM tables that contains

Sybase Transact-SQL – Adding Columns to existing Tables

Over the lifespan of a database driven application you may find that your existing database schema is not sufficient for new functionality. To maintain the integrity of your existing data Sybase and other SQL Servers enable administrators to modify existing tables by adding columns and constraints. SQL Format The basic format for the add column

Sybase Transact-SQL: Utilizing the GROUP BY and HAVING clause

What is the GROUP BY Clause? The GROUP BY clause of T-SQL is used to divide the results returned into groups.  This technique is often utilized to obtain aggregate information from the table as in the number of users you have from each state or number of books an author has written. In addition you

Sybase Transact-SQL: Overview of the DISTINCT command

The DISTINCT command: The DISTINCT command is used for retrieving unique data entries dependent on the columns specified. The opposite way of thinking about it is that it eliminates duplicate result rows. For a basic example lets assume we have the following person table and data First Name Last Name City State Matthew Denton Fayetteville

Pagination in Sybase: A Tutorial on how to use a Stored Procedure to perform Pagination in a Sybase database.

What is Pagination Pagination is the process of displaying a subset of the data on a web page at one time. The simplest example is a google search result in that after a search is performed you are displayed with the first x results as page 1. Then utilizing the page handlers you are able

Code Snippets: How to obtain the next identity value from a Sybase Table

There are a few methods available to the Sybase Transact-SQL developer who needs to obtain the next primary key for the next row to be inserted. If the primary column is an identity column then the next_identity function can be used. The proper syntax is: SELECT next_identity( “TABLE_NAME” ) If however you have not used

SYBASE ASE :: Create Table Transact-SQL Syntax – An Overview

SYBASE Adaptive Server Enterprise (ASE) is a relational model database server, that uses Transact-SQL (T-SQL) as the procedural language for creating, modifying and querying the Databases. Detailed below is a short overview of how to create tables in an ASE Database Server including auto generating ID SEQUENCES, foreign keys, and unique indexes. Basic Format Like