Sunday, June 10, 2012

How to use XML DataType of SQL Server with C#.NET

Some time we required to insert XML data in sql server through the use of C#.NET, You can do it after execution the some line of code.

1) create an XML formated data in C# either using loop or from any other way, for eg.


2) create an stored procedure in sql server


CREATE PROCEDURE [dbo].[ProcedureName]
(
@XMLData XML
)
AS
BEGIN
UPDATE table SET PRICE_1YEAR=TempData.Item.value('@PRICE_1YEAR'
FROM @XMLData.nodes('/root/row') AS TempData(Item)
      WHERE ID=TempData.Item.value('@ID', 'INT') and PRODUCT_ID =TempData.Item.value('@PRODUCT_ID', 'INT')END

Case Sensitive Search on a Case Insensitive SQL Server

Question
Most of the SQL Server installations are installed with the default collation which is case insensitive. This means that SQL Server ignores the case of the characters and treats the string 'Harish Kumar' equal to the string 'harish kumar'. If you need to differentiate these values and are unable to change the collation at the server, database or column level, how can you differentiate these values?
Answer
1) As you can see, this SQL Server has a case insensitive collation i.e. CI.
    SELECT SERVERPROPERTY ('Collation')
      Ans: SQL_Latin1_General_CP1_CI_AS

2) How can I just capture the rows with the mixed case
     SELECT *      FROM dbo.TableName WHERE Column1 LIKE '%Test%' Collate SQL_Latin1_General_CP1_CS_AS

Thursday, June 7, 2012

Delete Project in VSTS(Visual Studio Team Foundation Server) 2008


Introduction


I tried to remove a project  from TFS 2008 server, I have searched all the possible options available in System but can't able to do it from TFS panle after this I searched the solution of this problem Now I am going to share how to delete a project on TFS.
Solution
To delete a project, Open up the command prompt in the server, move to the location “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\”. The location can vary based on your installation. Check for the file "tfsdeleteproject.exe".
TFSDeleteProject Syntax and Parameters

TFSDeleteproject [/q] [/force] [/server:servername] team project name
for eg: tfsdeleteProject /q /force /server:ComputerName tfsProjectName 
Where:
  • /q: Silent installation. No prompt
  • /force: If data can't be deleted, still continue
  • /server: your TFS server: Name of the Team Project to delete. If there are spaces in the name, use quotes.
Refer to the following screenshot.


 


Wednesday, May 23, 2012

How to resets the IDENTITY back to the SEED without using truncate table command?

TRUNCATE TABLE : TRUNCATE TABLE is a statement that quickly deletes all records in a table by deallocating the data pages used by the table. This reduces the resource overhead of logging the deletions

DELETE TABLE : DELETE TABLE statements delete rows one at a time, logging each row in the transaction log, as well as maintaining log sequence number (LSN) information. Although this consumes more database resources and locks, these transactions can be rolled back if necessary

Note:When large tables require that all records be deleted and TRUNCATE TABLE cannot be used, the following statements can be used to achieve the same result as TRUNCATE TABLE:
  • DELETE from "table_name"
  • DBCC CHECKIDENT("table_name", RESEED, "reseed_value")
eg: DBCC CHECKIDENT("Table1",RESEED,0)

How to round the value with the decimal place of 2 in C#?


The simple answer of the question is given below:

Math.Round(float.Parse("36.2568974"), 2).ToString();

Monday, May 7, 2012

Object Oriented Programming – Encapsulation is not just hiding data!

Encapsulation 
 
Encapsulation is hiding of process; hence you hide the data. Not the vice versa.

for example : The Coffee Vending Machine encapsulates the internal process and the ingredients (data) used in the process.

Abstraction
Abstraction is a concept which facilitates to extract out the essential information of an object.

for example
So, what exactly an Abstraction is?
Abstraction facilitates the easy conceptualization of real world objects, by eliminating the unnecessary details of the object. Unnecessary details? Yes, all the similar objects when you generalize, you will drop the uncommon details about the objects.
E.g., when you model a generic prototype for CRT Television & a Plasma Television, you look for details like Type of screen, Height, Width, thickness etc.; these are necessary details for a Television. But a Television object doesn't need to have details of what kind of Electron it will bean to power the CRT, what kind of liquid plasmas it will use to power the Plasma TVs. These kinds of details are unnecessary details.
 

for more information please click here 

Thursday, April 12, 2012

How to modify non-customizable entity in MS Dynamics CRM 4.0

In MS CRM 4.0 SQL database there is a table containing settings for all entities present in the system and it is called… Entity. In this table there is a column named IsCustomizable and this is set to 0 (zero) for the PriceList entity.

1 Open SQL Server Management Studio
2 Connect to MSCRM database (not the config one, but the real one with MSCRM tables)
3 Run following update command:

UPDATE ENTITY
SET ISCUSTOMIZABLE = 1
WHERE NAME = 'NonCustomizedEntityname'

Split the String values with a special character in MS Flow to convert this into Array

 Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...