Search This Blog

December 20, 2011

SilverLight Promlems and solutions

Q1. Disgner window displays the following error message without displaying silverlight GUI

System.ArgumentNullException
Value cannot be null.Parameter name: parentContext


ANS. Restart the VisualStudio and reload the project.

August 30, 2011

How to generate comma seprated values from rows of data in Sql Server

/*Before converting to comma separated values*/
SELECT NAME
FROM SYS.databases
order by name

/*Declare a variable to store the comma separated value*/
DECLARE @NameString VARCHAR(MAX)
SELECT @NameString =''

/*Convert the Rows to Comma Separated values*/
SELECT @NameString = @NameString + ISNULL(NAME,'')+', '
FROM SYS.databases
order by name

/* Remove the comma at the end of the value*/
SELECT @NameString = LEFT(@NameString,LEN(@NameString)-1)

/*Display the Comma seprated values*/
SELECT @NameString AS Name



Second Method


/*Before converting to comma separated values*/
SELECT NAME
FROM SYS.databases
order by name

/*Declare a variable to store the comma separated value*/
DECLARE @NameString VARCHAR(MAX)

/*Convert the Rows to Comma Separated values using COALESCE function*/
SELECT @NameString = COALESCE(@NameString + ', ','') + Name
FROM SYS.databases
order by name

/*Display the Comma separated values*/
SELECT @NameString AS Name


May 05, 2011

How to generate SQL (INSERT) Script for existing data in MS SQL Server

• Select the Database in SQL Server Management Studio (SSMS)
• Right Click on the Database
• Select Tasks then Generate Scripts
• In “Generate and Publish Scripts” wizard
• Select the required tables
• In “set Scripting Options” window select “Advanced
• Under General tab
o Types of data to script Select the value as “Data Only

July 01, 2010

Display all the tables and indexes present in a SQL Server database


SELECT
st.name AS [Table Name]
,si.name AS [Index Name]
,si.id AS [Index ID]
,IS_CLUSTERED = INDEXPROPERTY(si.id, si.name, 'IsClustered')
,IS_UNIQUE = INDEXPROPERTY(si.id, si.name, 'IsUnique')
FROM sys.tables st
LEFT OUTER JOIN sys.sysindexes si
ON st.name = OBJECT_NAME(si.id)
WHERE st.type = 'u'
AND OBJECTPROPERTY(si.id, 'IsMsShipped') = 0 /*leave out system tables*/
AND (si.indid BETWEEN 1 AND 254)
AND (si.Status & 64)=0 /*leave out AUTO_STATISTIC*/
ORDER BY st.name, si.name