My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Read Values of xml through tsql or sql querry

Monday, 19 September 2011






DECLARE @doc xml  ='<?xml version="1.0"?>

<dicom>

<attr len="2" vr="OB" tag="00020001">00\01</attr>

<attr len="22" vr="UI" tag="00020002">1.2.840.10008.5.1.4.33</attr>

</dicom>'                                                                                                       

declare @idoc int

select @doc


EXEC sp_xml_preparedocument @idoc OUTPUT, @doc



SELECT

tag,len,comment

FROM

OPENXML(@idoc, '/dicom/attr')

WITH

(tag varchar(30)

,len varchar(30)

,comment ntext 'text()'

)

Display Dates Between Two Dates in Sql Server

Thursday, 15 September 2011



DECLARE @StartDate DATETIME
SET @StartDate = '02/26/1988'

DECLARE @EndDate DATETIME
SET @EndDate = '03/01/1988'

DECLARE @TableOfDates TABLE(DateValue DATETIME)

DECLARE @CurrentDate DATETIME

SET @CurrentDate = @startDate

WHILE @CurrentDate <= @endDate
BEGIN
    INSERT INTO @TableOfDates(DateValue) VALUES (@CurrentDate)

    SET @CurrentDate = DATEADD(DAY, 1, @CurrentDate)
END

SELECT * FROM @TableOfDates

Add a column to a table if it does not exits

Thursday, 1 September 2011



Add a column to a table if it does not exits

IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS         
WHERE TABLE_NAME = 'TblSourceMaster' AND COLUMN_NAME = 'CorpSourceId')         
BEGIN         
   ALTER TABLE TblSourceMaster ADD CorpSourceId bigint NULL         
END        

 

Blogger news

Blogroll

Most Reading

8.6/10