Sunday, January 3, 2010

Alive Text to Speech

Alive Text to Speech is a text-to-speech software to read text in any application, and convert text to MP3, WAV, OGG or VOX files.

Alive Text to Speech also enables you to listen documents, emails, news articles or web pages without conversion. It supports schedule converting. It also allow advanced users to finish the conversion of text to mp3 with Command lines. You can change the different voices and the readout speed for conversion or listening, and download more voices from Internet.

Key Features:

1) Read text in any application, including Emails, web pages, news articles, PDF, Word or Excel Documents, etc.

2) Convert text to MP3, WAV, OGG, VOX files.

3) Convert text Files to MP3, WAV, OGG, VOX files.

4) Install Alive Text to Speech Toolbar in IE (Internet Explorer) Browser.

5) It is very simple and easy to use. Just right click on files in the Windows Explorer, select "Convert to MP3"(or WAV, OGG,VOX) and convert them using your predefined settings.

6) Command line supported.

7) Converting text to mp3 in batches.

8) Schedule converting support.

9) Microsoft text-to-speech engine.

10) High converting speed, wonderful output quality.

11) Windows Vista compatible

Site: http://www.alivemedia.net/textspeech.htm

SQL Server 2k5: How to Disable Management Studio's Splash Screen?

1. Right-click on the desktop.

2. Click New and select Shortcut.

3. Click the Browse button and go to the Sqlwb executable (”C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Sqlwb.exe”).

4. After the full path and the end quotes, add one space and type in -nosplash.

5. Click Next.

6. Type a name for the shortcut.

7. Click Finish.

MS SQL 2k5: Steps to Reset sa Account Password

1. Open the SQL Server Management Studio.

2. Open a New Query.

3. Copy, paste, and execute the following:

GO
ALTER LOGIN [sa] WITH DEFAULT_DATABASE=[master]
GO
USE [master]
GO
ALTER LOGIN [sa] WITH PASSWORD=N'NewPassword' MUST_CHANGE
GO

where NewPassword is the password you wish to use for the sa account.

Monday, March 30, 2009

Choose proper datatype – float vs decimal

"The float and real data types are known as approximate data types.... For many applications, the tiny difference between the specified value and the stored approximation is not noticeable. At times, though, the difference becomes noticeable. Because of the approximate nature of the float and real data types, do not use these data types when exact numeric behavior is required, such as in financial applications, in operations involving rounding, or in equality checks. Instead, use the integer, decimal, money, or smallmoney data types."

 http://msdn.microsoft.com/en-us/library/ms187912(SQL.90).aspx

 For Example:

Consider column is defined as float and has a value of 0.01384981270568965. When same column value is queried from Query Analyzer then it returns 0.0138498127056897

So always choose proper data type before creating the table.

How to display only first and last record using TSQL


Here let us see how to get only first and last record of a table. 

Note: For demonstration purpose I am using 'Orders' table of the Northwind database. 

Query:

/*Query: 1 - To show all the records in orders table*/

SELECT * FROM ORDERS ORDER BY CustomerId ASC, OrderDate ASC


/*Query: 2 - To fetch first and last record in orders table*/

WITH CTETable

AS

(SELECT OrderId, CustomerID,OrderDate,Freight,ShipName,

ROW_NUMBER() OVER(PARTITION BY CustomerID ORDER BY OrderDate) as StartRec,

ROW_NUMBER() OVER(PARTITION BY CustomerID ORDER BY OrderDate DESC) as EndRec

FROM ORDERS)

SELECT OrderId, CustomerID,OrderDate,Freight,ShipName

FROM CTETable WHERE StartRec=or EndRec=1

ORDER BY CustomerId ASC, OrderDate ASC

Output:

Here query: 1 will display all the rows in the orders table and query: 2 will display only first and last records in the orders table which is show below:

How to take a full and differential backup using T-SQL

Regularly backup’s of your database is very important. A lot of people know how to take a backup using SQL Server Management Studio (SSMS).

Here is the T-SQL command which shows how to take a full and differential database backup in SQL Server 2005/2008.

Note: In order to do a differential backup, full backup of the database needs to exist first since a differential backup copies all the data and log info that have been changed since the last backup.

Full backup:

-- Full database backup needs to exist

 -- before a Differential backup is taken

 BACKUP DATABASE AdventureWork

    TO DISK = 'C:\BackUpFolder\AdventureWork_Full_20090230.bak'

    WITH DESCRIPTION = 'First BackUp Of Adventure Work Database',

    INIT

 GO

·         INIT parameter overwrites existing backups preserving the media header.

·         DESCRIPTION is for keeping notes about the backup.

Note: 'BackUpFolder' should exist before you executing it

Differential backup:

-- Create a differential db backup

 -- appending the backup to the full backup

 BACKUP DATABASE Northwind

    TO DISK = 'C:\ BackUpFolder\ AdventureWork_Diff_20090230.diff'

    WITH DIFFERENTIAL,

    NOINIT,

    STATS= 50

 GO

 ·         STATS gives additional info about the progress during a backup.

  

Sunday, March 29, 2009

How to create output as CSV using FOR XML and multiple rows

For example consider source data as follows

Source data:

Group

Value

1

1

1

2

1

3

1

4

2

3

2

2

2

1

3

1

3

2












Result required:

Group

Value

1

1,2,3,4

2

3,2,1

3

1,2



FOR XML only gets you so far, well – 1 row to be exact, so how do we break it out for the multiple rows per group?

The trick is to use a sub-query on the SELECT and wrap your FOR XML logic into that…

Source code:

--Declaring temporary table variable

declare @tb table(agrp int,aval int)

--Inserting data(s) into temporary table

insert @tb values(1, 1)

insert @tb values(1, 2)

insert @tb values(1, 3)

insert @tb values(1, 4)

insert @tb values(2, 3)

insert @tb values(2, 2)

insert @tb values(2, 1)

insert @tb values(3, 1)

insert @tb values(3, 2)

 

--Query to print the desired output

SELECT r.agrp,

       collapsed = LEFT(r.collapsed, LEN(r.collapsed) - 1)

FROM   (

           SELECT a.*,

                  collapsed = (

                      SELECT CAST(aval AS VARCHAR(MAX)) + ',' AS [text()]

                      FROM   @tb b

                      WHERE  b.agrp = a.agrp

                             FOR XML PATH('')

                  )

           FROM   (

                      SELECT DISTINCT agrp

                      FROM   @tb

                  ) AS a

       ) AS r


Output screenshot: