Wednesday, March 16, 2011

It is not funny

It is always good to research before trying out. Windows 7 64-bit does not recognize 64-bit CPU in Virtual PC.

Monday, March 07, 2011

SQL Server compound statment operator support?

compound assignment operators. Here is a working example of those operators:

declare @i int
set @i = 100

/**************************
Addition and assignment
***************************/
set @i += 1
select @i

———–
101

/**************************
Subtraction and assignment
***************************/
set @i -= 1
select @i

———–
100

/**************************
Multiplication and assignment
***************************/
set @i *= 2
select @i

———–
200

/**************************
Division and assignment
***************************/
set @i /= 2
select @i

———–
100

/**************************
Addition and assignment
***************************/
set @i %= 3
select @i

———–
1

/**************************
xor operation and assignment
***************************/
set @i ^= 2
select @i

———–
3

/**************************
Bitwise & operation and assignment
***************************/
set @i &= 2
select @i

———–
2

/**************************
Bitwise | operation and assignment
***************************/
set @i |= 2
select @i

———–
2

using SQL Server strongly typed table variable

The following code is an illustration of how to use strongly typed table variable.

1. create type
create type typ as table (id int);

2. create table
create table temp(id int not null)

3. create procedure

create procedure myproc
@t typ readonly
as

insert into temp
select * from @t typ

4. run

declare @mytype typ
insert into @mytype values(1), (2), (3)
exec myproc @mytype

Microsoft Secure Cloud Service for SQL Server Deployments

Microsoft just released a configuration assessment cloud service that helps to check your SQL Server configration deployments and enable DBA's proactively avoid configration problems. But for the tool to work it needs to be installed on Windows server box. So, if you want to play with it then you need a server. It will install both gateway and agent. But you only required to install agent if you don't need it to monitor SQL Server 2008.

To download the new tool or read more you can Read about atlanta (Cloud sql config)

I definately wouldn't put this product on produciton server but can check on my development and test servers to check if the configration is right. The tool collects all configration information and uploads to microsoft portal.

First preview of the portal is shown below.

Wednesday, February 23, 2011

Table Parameters and Table Types

A new feature in SQL 2008 is table-valued parameters. You can pass a table variable as a parameter to a stored procedure. When you create your procedure, you don't put the table definition directly in the parameter list of the procedure, instead you first have to create a table type, and use that in the procedure definition. At first glance it may seem like step of extra work, but when you think of it, it makes very much sense: you will need to declare the table in at least two places, in the caller and in the callee. So why not have the definition in one place?

Here is a quick example that illustrates how you do it:

CREATE TYPE my_table_type AS TABLE(a int NOT NULL,
b int NOT NULL)
go
CREATE PROCEDURE the_callee @indata my_table_type READONLY AS
INSERT targettable (col1, col2)
SELECT a, b FROM @indata
go
CREATE PROCEDURE the_caller AS
DECLARE @data my_table_type
INSERT @data (a, b)
VALUES (5, 7)
EXEC the_callee @data
go

So this is the final solution that makes everything else I've talked of in this article of academic interest? Unfortunately, it's the other way round. See that word READONLY in the procedure definition? That word is compulsory with a table parameter. That is, table parameters are for input only, and you cannot use them to get data back. There are of course when input-only tables are of use, but most of the time I share a temp table or use a process-keyed table it's for input-output or output-only.

Using the cursor Data Type in an OUTPUT Parameter

A comprehensive example of how to use cursor data type in an output parameter. If you are interested view it @

Thursday, February 17, 2011

What is New in SQL Server "Denali" (part II)

1. Encryption

SQL Server 2008 R2 supports MD2, MD4, MD5, SHA, or SHA1 hash algorithms for encryption of you data. The new release add support for SHA2_256 and SHA2_512 algorithms. You can use HASHBYTES function as previous version.

2. User defined server role

One of the new security features added to Denali is the ability for user now to add user defined server roles which wasn't possible in the previous versions. User can now create, drop, alter user defined server roles.

3. SQL server security model

Users don't require logins when access to contained database is permitted. This is a big change and an area that needs to be looked at properly. To understand how this is implemented you can get more info Designing and Implementing a Contained Database

4. New permission

Due to the addition of user defined server role, there are also associated permission. Permission to grant, deny and revoke on user defined server roles.

Monday, February 14, 2011

What is New in SQL Server "Denali" (part I)

Part I : Availability and manageability Enhancements

As we all know microsoft is working on the next generation of SQL Server called Denali. It is at early stages to say what will be released but I would like to go through some of the features.


1. HADR


The introduction of the "HADR" solution for enhancing availability of user databases in an enterprise environment. This new enhancement of the database engine will help database administrators to enable to maximize availability for one or more of your user databases. HADR is a high-availability and disaster-recovery solution that provides an enterprise-level alternative to database mirroring. For more information , overview and to deploy, configure and administer HADR please refer to HADR

2.Combination of BIDS and Management studio


As we all know SQL Server managment studio was a one stop shop for your SQL server development and administation. The same is also true of Business Intellegence development studio (BIDS). The new version of SQL server will combine the two studio into one IDE. I think this is pretty cool.

3.Column-Based Query Accelerator

Column-Based Query Accelerator will help dramatically increase query performance ~10x as per microsoft's claim. I will probably test if this statement is true and will post my results on this blog. Colum base query accelerator will reduce performance tuning through interactive experiences with data for near instant response times and streamlined setup which removes the need to build summary aggregates.

4.SQL Server Management Studio enhancements

The Database EngineQuery Editor introduces enhanced functionality for Transact-SQL debugging and IntelliSense. Ability to debug T-SQL running on SQL2005 SP2 and later,
The Watch window and Quick Watch can now be used to watch T-SQL expressions,
Moving your cursor over T-SQ identifier will bring up a quick info pop up that displays the name of the expression and its value are just few of many new features that has been introduced in the next version of SQL Server

5. PowerShell

Windows powershell is no more part of the SQL server installation but it is part of pre-requisite. I am not sure if this is considered to be a new feature but nice to know.

6.Contained Databases
In new version of SQL server when moving a database from one instance of database engine to another instance, the dependancy of users in a contained database no longer associated with the logins on the instance. Microsoft claims that many other depenpendencies on the instance is also removed. For more info on contained database and the terms @read more on contained database

7. Database engine start-up options

Database start up option is now configured from SQL server configration manager.

Thursday, May 13, 2010

Install SQL server R2 issue

Today I faced with the following error while trying to install SQL server 2008 R2.
Sql2005SsmsExpressFacet:Checks whether SQL Server 2005 Express Tools are installed. FailedThe SQL Server 2005 Express Tools are installed. To continue, remove the SQL Server 2005 Express Tools.

I checked and there was no installation of SQL server express edition.

I then started looking at the registery and the only thing I need to do was to rename one entry in registry. Find shellSEM in the registery and rename it

The full path of the registry location is
HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM

Finding all SQL server on your network from sql server 2005/08

By default xp_cmdshell is disabled on SQL server 2005/08. You need to enable this using


sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO


you can then run OSQL command as follows

EXEC master..XP_CMDShell 'OSQL -L'

Friday, December 04, 2009

sqlcmd 512 characters bug (On SQL server 2008 R2)

On SQL server 2008 R2 November CTP using sqlcmd to output file will result in truncated characters. I have tried this on my PC numerous times and still not getting more than 512 characters.

I have used the following command

sqlcmd -E -S -d master -Q "PRINT REPLICATE('this is testing for more than 512 characters',1000)" -b -o C:\NoMorethan512characters.txt

The above command produced only 512 characters. After further investigation, I found out that this has been reported as a feedback on Microsoft connect sqlcmd 512 characters still not registered as a bug by Microsoft. I hope this is going to be fixed soon.

Monday, November 30, 2009

Transparent Data Encryption (SQL server 2008)

Transparent Data Encryption (TDE) is a new feature in SQL server 2008.
TDE is a new feature in SQL Server 2008; it provides real time encryption of data and log files. Data is encrypted before it is written to disk; data is decrypted when it is read from disk. The "transparent" aspect of TDE is that the encryption is performed by the database engine and SQL Server clients are completely unaware of it. There is absolutely no code that needs to be written to perform the encryption and decryption. There are a couple of steps to be performed to prepare the database for TDE, then the encryption is turned on at the database level via an ALTER DATBASE command.

Friday, November 27, 2009

SQL Server Management Studio Support for SQL Azure

Do you know that SQL Server 2008 R2 November CTP have added support for Server Management Studio Support for SQL Azure ? I cannot wait to play with it.

Microsoft SQL Azure™

Microsoft SQL Azure is the part of the new windows Azure platform. It seems to me that Microsoft is trying to address, get into and/or use the new hype surrounding cloud computing. I don't see this offering different from oracle on demand that has been there for long. I am not sure also after seeing oracle on demand how good the offering is.

Microsoft claims that
SQL Azure Database provides Internet-facing database and advanced query processing services and is the ideal solution for customers building new applications or integrating with existing investments into the cloud.
I will wait and see.

Microsoft sql server case studies

Who start using sql server ? Some eye catching case studies can be found @Microsoft SQL server case studies

Tuesday, November 24, 2009

SQL Server 2008: Benchmarks

Top Ten TPC-E database performance benchmarks carried out by TPC (Transaction processing benchmark council) @ SQL Server 2008: Benchmarks

SQL Server compared to Oracle

Microsoft view of comparison between SQL server 2008 and oracle 11G. Microsoft claims that Microsoft® SQL Server® 2008 outperforms Oracle in the areas that matter to business. I am not sure what this mean. But you can see this interesting comparison by Microsoft @SQL Server compared to Oracle

Monday, November 23, 2009

Microsoft SQL Server Playback Program

Microsoft have introduced a Microsoft SQL Server Playback Program. For more information on how the program works you can download and see and view
  • program overview

  • goals of the program

  • if you would be able to participate

  • processes and procedures that is required

  • benefit to customers who participate in the progaram

  • and more can be found @ Microsoft SQL Server Playback Program

    Thursday, November 19, 2009

    Microsoft SQL Server 2008 R2

    What is new in Microsoft SQL Server 2008 R2?

    1. Master Data Services
    Microsoft SQL server 2008 R2 contains a master data management applications. Master data services have got the following tools.

  • Master Data Services Configuration Manager. This configuration manager will help you to create and configure master data services databases and web applications
  • Master data services web service. This component is more useful to developers as they would be able to extend or develop custom solutions for master data services
  • Master Data Manager. This is used by users to manage master data

  • 2. PowerPivot for SharePoint
    Microsoft SQL Server PowerPivot for SharePoint extends SharePoint 2010 and Excel Services to add server-side processing, collaboration, and document management support for the PowerPivot workbooks that you publish to SharePoint.


    3. Multi-Server Administration and Data-Tier Application
    Full details of this new feature can be found @Multi-Server Administration

    4. Support or 256 logical processors


    Support for 256 logical processor is now added in R2 but this requires to be run on Windows 2008 R2. This is a big jump from previous maximum value of 64 processors. Quite a bit jump in my opinion.

    5. Support for visualization of geographic spatial data in Reporting Services
    Support for reports with visual geographic mapping is now supported in SQL Server 2008 R2.