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

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, ...