December 30, 2011

SQL Script to get the size of Sql Index

SELECT Indextable.Name, Indextable.type_desc, 
PhysicalStat.page_count, PhysicalStat.record_count, PhysicalStat.index_level
FROM sys.indexes Indextable
JOIN sys.dm_db_index_physical_stats( DB_ID(N'CustomerNew'), OBJECT_ID(N'dbo.Customers'), NULL, NULL, 'DETAILED')
AS PhysicalStat
ON Indextable.index_id = PhysicalStat.index_id
WHERE Indextable.OBJECT_ID = OBJECT_ID(N'dbo.Customers')

December 28, 2011

MS Sql Server - ManagedDTS

This script bellow is for calling the SSIS package from C#.

You may don't have the Dts library as default, so you mostly can find it from the path here:
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS\9.0.242.0__89845dcd8080cc91

using System;
using Microsoft.SqlServer.Dts.Runtime;

namespace Microsoft.SqlServer.Dts.Samples
{
class ApplicationTests
{
static void Main(string[] args)
{
// The variable pkg points to the location of the
// ExecuteProcess package sample that was installed with
// the SSIS samples.
string pkg = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services" +
@"\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

Application app = new Application();
Package p = app.LoadPackage(pkg, null);

// Now that the package is loaded, we can query on
// its properties.
int n = p.Configurations.Count;
DtsProperty p2 = p.Properties["VersionGUID"];
DTSProtectionLevel pl = p.ProtectionLevel;

Console.WriteLine("Number of configurations = " + n.ToString());
Console.WriteLine("VersionGUID = " + (string)p2.GetValue(p));
Console.WriteLine("ProtectionLevel = " + pl.ToString());
Console.Read();
}
}
}

December 12, 2011

MS Sql Server Installation on Windows 7

Visual Studio and SQL Server on Windows 7 RC

When attempting to install SQL Server 2008 RTM or SQL Server 2005 RTM/SP1/SP2 on Windows 7 RC, you will receive a warning dialog stating that SQL Server has known compatibility issues with this version of Windows. Since SQL Server is redistributed by Visual Studio, installations in which the user selects to install SQL Server along with Visual Studio will be affected. The issues that trigger the compatibility warning have been fixed in SQL Server 2008 SP1 and SQL Server 2005 SP3.

The recommended workaround is to install Visual Studio with SQL Server and then upgrade to SQL Server 2008 SP1 or SQL Server 2005 SP3 using Windows Update. You can also choose to install SQL Server 2008 SP1 before installing Visual Studio.

The steps below are shown for installing Visual Basic 2008 Express Edition with SP1 plus SQL Server 2008 on Windows 7 RC:

1. Download Microsoft Visual Basic 2008 Express Edition with SP1 from the Express download page.
2. During setup, make sure to select “Microsoft SQL Server 2008” from the “Optional Components” page.
3. As soon as SQL Server 2008 installation begins, you will receive a compatibility warning dialog.
4. Select Run Program to continue the installation.
5. You will then be presented with a second compatibility warning dialog when running “setup.exe”. Select Run Program again.
6. After installation has completed, launch Windows Update.
7. Select Check for updates in the left-hand pane.
8. Under the optional updates, you should see a checkbox for “Microsoft SQL Server 2008 Service Pack 1”.
9. If for some reason, you don’t see “Microsoft SQL Server 2008 Service Pack 1” listed as an optional update, please go here to download the service pack.
10. Check the box next to the entry and select OK.
11. Windows update will then install SQL Server 2008 SP1.
12. Once installation has completed, you may be prompted to reboot.

December 02, 2011

ASP.NET Ajax








var xmlHttp = null;
function xmlRequest(){
if(!xmlHttp) InitXmlHttp();
xmlHttp.open('GET','StatesList.html', false);
xmlHttp.send(null);
var content = xmlHttp.responseText;
var locations = document.getElementById('Locations');

if(content && locations)
locations.innerHTML = content;
}
function InitXmlHttp(){
try{
xmlHttp = new XMLHttpRequest();
}catch (ex){}
try{
xmlHttp = new ActiveXObject('Msxml2.XMLHTTP.4.0');
}catch (ex){}
try{
xmlHttp = new ActiveXObject('Msxml2.xmlhttp');
}catch (ex){}
}