Archive for the ‘SQL’ Category

SQL: New versions of SQL Server 2008 Express

Wednesday, May 13th, 2009

Microsoft has released three versions of SQL Server 2008 Express Edition, these are:
* Microsoft SQL Server 2008 Express, this is the basic version of SQL Server 2008 Express Edition, this version with other applications redistribution is free.

* Microsoft SQL Server 2008 Express Tools with this version gives us work with applications that work with data, whether to narrow or web development, this version is ideal for small server storage applications and data storage, among the features best we can name:

* Admin Tools reliable and effective.
* Interesting data protection system.

* Microsoft SQL Server Express 2008 with Advanced Services includes more features and makes it easier than ever to develop effective data-driven applications for the web or local desktop. Other features include:

* A graphical management tool.
* Interesting features to create reports.
* Run reports from SQL Server Reporting Services on local relational data.

Link: Microsoft SQL Server 2008 Express,
Link: Microsoft SQL Server 2008 Express Tools
Link: Microsoft SQL Server Express 2008 with Advanced Services

An Introduction to SQLite

Friday, May 8th, 2009

http://www.wisecodes.com/2009/05/an-introduction-to-sqlite/

SQLite is a small library written in C, which offers an engine for database SQL and implementing much of the standard SQL92 and ACID properties. In contrast to database servers like MySQL or PostgreSQL, its particularity is not to reproduce the usual client / server but to be integrated directly to programs using database files. SQLite is a public domain project created by D. Richard Hipp .

SQLite is the database engine as distributed through its offices in many large public software Skype, Firefox, Gears, and some products McAfee, in many languages like PHP, Python and Perl and some mobile phones whose iPhone and those running Symbian, which totals more than 200 million settlement of the library.

Features:

SQLite does not work on the paradigm client / server, but is a function library. Among its other features, it should be noted:

  • the absence of a procedure for installation and configuration. This includes the lack of account management and user rights.
  • whole database is stored in one file.
  • the type of data stored in each database is a property of the data, not the column. A column can contain data of different types.

SQLite implements most of the SQL 92 standard with the exception of:

  • management rights with GRANT and REVOKE
  • management of foreign keys
  • the joints type RIGHT OUTER JOIN and FULL OUTER JOIN (but supports LEFT OUTER JOIN)
  • the triggers are only partially taken into account
  • the possibilities of modifying the structure of a table are limited: you can rename a table and add columns, but not modify or delete columns.

SQLite can be interesting in performance and be useful in many cases (unable to use a database server for websites or applications and embedded devices, etc..), But it does not allow different processes or thread to access simultaneously write to the same database and is not designed to handle a lot of competitors.

The library can be used in Python, C and C + +. Modules for Perl, PHP, TCL and other scripting languages are available.

PHP includes SQLite in the distribution base since version 5, when it was released as version 4 in the form of an extension PECL.

Python SQLite 3 also includes in its standard library since version 2.5.

Link: Offical Website of SQLite
Link: Interview with Richard Hipp
Link: SQLiteSpy (compatible with Unicode for Win32. Freeware.)
Link: SQLite Database Browser
Link: SQLite Database Manager

Video: (An Introduction to SQLite)

SQL: Get First and Last Day of Week

Monday, May 4th, 2009

Description:
How to get First and Last Day of Week.

Select GETDATE() AS 'Today', 

DATEPART(Week,GETDATE()) AS 'Week No of Today', 

DATEADD( DAY , -DATEPART(WEEKDAY,(DATEADD( DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE())))
+(7-DATEPART(WEEKDAY,GETDATE()))+1 ,GETDATE()) 'First Day Of This Week', 

DATEADD(DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE()) AS 'Last Day Of Week'

Happy Programming!!

SQL: Get column names of a specified table.

Monday, May 4th, 2009

Description:
How to get column names of a specified table then do this code .

SELECT COLUMN_NAME As 'Columns' , DATA_TYPE As 'Type' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Your_Table_Name' ORDER BY ORDINAL_POSITION

OR

SELECT [NAME] AS 'Columns' FROM SYSCOLUMNS WHERE [ID] = Object_Id('Your_Table_Name')

Read More about INFORMATION_SCHEMA.COLUMNS 
Read More about SYSCOLUMNS

Happy Programming!!

Intro to Transact-SQL (T-SQL)

Thursday, April 30th, 2009

Transact-SQL (T-SQL) is an extension of the SQL standards by Sybase and Microsoft and includes error handling, row processing and variable declaration.

Usage:
You can programs (stored procedures) on the database server and thus extend the database functionality, each user of the database can call up these programs and use. The permissions may be established for each Transact-SQL procedure to an individual user basis.

External links:

  1. Transact-SQL Reference by Microsoft for MS-SQL 2008
  2. Transact-SQL Reference for Sybase Adaptive Server Enterprise 12.5.1
  3. T-SQL Factsheet for developers as PDF

Microsoft SQL Server JDBC Driver 2.0

Thursday, April 30th, 2009

The JDBC driver supports the features of JDBC 4.0 API.

You can check the features here:

Download URL:
http://www.microsoft.com/downloads/details.aspx?FamilyID=99b21b65-e98f-4a61-b811-19912601fdc9&displaylang=en

Linking remote servers in SQL Server

Monday, April 13th, 2009

To the point:

See the linked servers that have:

exec sp_linkedservers

Add a new remote server to your links:

EXEC sp_addlinkedserver
@ server = 'server'
@ srvproduct ='product_name'
@ provider = 'provider_name'
@ datasrc = 'data_source'

Add credentials to access a remote server:

EXEC sp_addlinkedsrvlogin 'RemoteServerName', 'false', NULL, 'username', 'password'

And Hale, to throw the linked server.

More info on MSDN, here and here.

Happy Programming!!

SQL Server 2005 Tools

Monday, April 6th, 2009

Inside SQL Server 2005 you can find the following tools:

Database Services: Includes the database engine and components of search. The database engine is the core of SQL Server. Replication increases the availability of data among various databases, allowing to scale the workload of each server. The search query language allows level within the data stored in a database.

Analysis Services: Provides functionality for OLAP and Data Mining aimed at Business Intelligence applications. Analysis Services allows you to add data from multiple sources, including relational databases and data work in several ways.

Data Integration Services: Delivery data transformation and integration solutions to extract and process data from multiple sources and directions to one or more destinations. This link allows data from multiple sources and load data in the Data Warehouse.

Notification Services: includes a notification engine and components for customers to create and send personalized messages each time an event occurs. The notifications can be sent to wireless devices like cell phones or PDA’s, or Mail Messenger accounts.

Reporting Services: includes Report Manager and Report Server to provide a complete platform for creating, managing and distributing reports. Report Server is built on standard IIS and technology. NET Framework, allowing lso combine benefits of SQL Server and IIS for hosting and processing reports.

Service Broker: Allows creation of queues and messaging as the core of the database. Queues can be used to stack work, consultations and other applications, and implemented as resources become available. Messaging allows applications that use databases to communicate with them.

Cheers!!!

Add/Remove NewLine in SQL Query

Friday, February 13th, 2009

Add NewLine in SQL Query:

 
  Code:
Declare @FristName Char(10)
Declare @LastName Char(10) 
 
Set @FristName = 'Venu'
Set @LastName = 'Thomas' 
 
Select (@FristName + CHAR(13) + CHAR(10)+ @LastName) As Name
   

OutPut:

Name  
———————- 
Venu      
Thomas    

(1 row(s) affected)
 

Remove NewLine in SQL Query:

Code:


Declare @FristName Char(5)
Declare @LastName Char(10) 
Declare @strName Char(15) 
 
Set @FristName = 'Venu'
Set @LastName = 'Thomas'  
 
Set @strName =@FristName + CHAR(13) + CHAR(10)+ @LastName 
 
Select Replace(Replace(@strName, CHAR(13), ''), CHAR(10), ',') As Name
   

OutPut:

Name
————
Venu ,Thomas
(1 row(s) affected)