Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Thursday, March 29, 2012

Embedding SQL Server Express in the installer

Can we embed the SQL Server Express in the windows installer jsut like the XML files or the Ms access database?You are referring to the windows installer in VS 2005 I suppose ??
It is not possible in the installer of VS 2003, but I suppose it can be done with Whidbey ... I haven't tried it yet though ...|||The following information may provide clarification regarding the same;

Can I redistribute SQL Express?
http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172952.aspx

Friday, February 24, 2012

element vs attribute!

I ran into an interesting issue.
Can anyone help explain why I'm able to load my xml data as an attribute but
I'm not able to load my data when it is configured as an element?
I have XML data that I bulkload into SQL2005. I'm able to load example data
into my second table by configuring my data as an attribute like this:
<SDOCL CLMSEQ="1" CLM="1. Reason for claim">
<SDOCL CLMSEQ="2" CLM="2. Reason for claim 2">
I modified my XSR mapping file (show below) to load the data as an Element
which would be a much better solution for me.
When I run my script I receive an error "Schema: missing element definition
'CLMSEQ'"
When I add the element type for CLMSEQ & CLM "<ElementType name="CLMSEQ"
dt:type="string" />" I receive this error "Datamapping to column CLM was
already found in the data. Make sure that no two schema definitions map to
the same column."
Any ideas?
My XML file is formatted like this:
<PATDOC>
<B110> 1 </B110>
<SDOCL>
<CLM> 1. Reason for this claim </CLM>
<CLMSEQ> 1 </CLMSEQ>
</SDOCL>
<SDOCL>
<CLM> 2. Reason for this claim </CLM>
<CLMSEQ> 2 </CLMSEQ>
</SDOCL>
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql" >
<ElementType name="B110" dt:type="string" />
<ElementType name="PATDOCS" sql:is-constant="1">
<element type="PATDOC" />
</ElementType>
<ElementType name="SDOCL" sql:relation="Claims" >
<element type="CLM" sql:field="CLM" />
<element type="CLMSEQ" sql:field="CLMSEQ" />
</ElementType>
<ElementType name="PATDOC" sql:relation="Pdata">
<element type="B110" sql:field="B110" />
<element type="SDOCL">
<sql:relationship
key-relation="Pdata"
key="B110"
foreign-key="B110"
foreign-relation="Claims" />
</element>
</ElementType>
</Schema>
This example xml and xsd work for me if I add the ElementType declarations.
However you might get the error message you referred to if you were to
include multiple CLM/CLMSEQ pairs under a SDOCL element like:
<SDOCL>
<CLM> 1. Reason for this claim </CLM>
<CLMSEQ> 1 </CLMSEQ>
<CLM> 2. Reason for this claim </CLM>
<CLMSEQ> 2 </CLMSEQ>
</SDOCL
If your xml was shaped like this you would need to add an additional layer
of elements to group the pairs together:
<SDOCL>
<CLMPAIR>
<CLM> 1. Reason for this claim </CLM>
<CLMSEQ> 1 </CLMSEQ>
</CLMPAIR>
<CLMPAIR>
<CLM> 2. Reason for this claim </CLM>
<CLMSEQ> 2 </CLMSEQ>
</CLMPAIR>
</SDOCL
"Charles W" wrote:

> I ran into an interesting issue.
>
> Can anyone help explain why I'm able to load my xml data as an attribute but
> I'm not able to load my data when it is configured as an element?
>
> I have XML data that I bulkload into SQL2005. I'm able to load example data
> into my second table by configuring my data as an attribute like this:
> <SDOCL CLMSEQ="1" CLM="1. Reason for claim">
> <SDOCL CLMSEQ="2" CLM="2. Reason for claim 2">
>
> I modified my XSR mapping file (show below) to load the data as an Element
> which would be a much better solution for me.
>
> When I run my script I receive an error "Schema: missing element definition
> 'CLMSEQ'"
> When I add the element type for CLMSEQ & CLM "<ElementType name="CLMSEQ"
> dt:type="string" />" I receive this error "Datamapping to column CLM was
> already found in the data. Make sure that no two schema definitions map to
> the same column."
>
> Any ideas?
>
>
> My XML file is formatted like this:
> <PATDOC>
> <B110> 1 </B110>
> <SDOCL>
> <CLM> 1. Reason for this claim </CLM>
> <CLMSEQ> 1 </CLMSEQ>
> </SDOCL>
> <SDOCL>
> <CLM> 2. Reason for this claim </CLM>
> <CLMSEQ> 2 </CLMSEQ>
> </SDOCL>
>
>
> <?xml version="1.0" ?>
> <Schema xmlns="urn:schemas-microsoft-com:xml-data"
> xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
> xmlns:sql="urn:schemas-microsoft-com:xml-sql" >
>
> <ElementType name="B110" dt:type="string" />
>
> <ElementType name="PATDOCS" sql:is-constant="1">
> <element type="PATDOC" />
> </ElementType>
>
> <ElementType name="SDOCL" sql:relation="Claims" >
> <element type="CLM" sql:field="CLM" />
> <element type="CLMSEQ" sql:field="CLMSEQ" />
> </ElementType>
>
> <ElementType name="PATDOC" sql:relation="Pdata">
> <element type="B110" sql:field="B110" />
>
> <element type="SDOCL">
> <sql:relationship
> key-relation="Pdata"
> key="B110"
> foreign-key="B110"
> foreign-relation="Claims" />
> </element>
> </ElementType>
> </Schema>
>
>

element centric XML for XML explicit - suggestion needed

my xml would be like.
<X>
-<XY>
-<XYZ>
<![CDATA[ hello adkfsd ]]>
</XYZ>
-<XYZ1>
<![CDATA[ hell adkfsd ]]>
</XYZ1>
<XY>
<XY1>
...
</XY1
</X>
it is very element centric . All the data comes from a single table.
here just for mentioning the parent tag for the datas i need to write a
select.
i wrote a query which had 6 selects and got the XML.
two of the select querys were written just to include the name for the
parent tag.
can someone pls tell me if its possible to improvise..
is it possible to use for xml auto and get CDATA..
waiting for ur replies,
tobyToby wrote:

> my xml would be like.
> <X>
> -<XY>
> -<XYZ>
> <![CDATA[ hello adkfsd ]]>
> </XYZ>
> -<XYZ1>
> <![CDATA[ hell adkfsd ]]>
> </XYZ1>
> <XY>
> <XY1>
> ...
> </XY1
> </X>
>
> it is very element centric . All the data comes from a single table.
> here just for mentioning the parent tag for the datas i need to write a
> select.
> i wrote a query which had 6 selects and got the XML.
> two of the select querys were written just to include the name for the
> parent tag.
> can someone pls tell me if its possible to improvise..
> is it possible to use for xml auto and get CDATA..
Do you really need CDATA Sections? They are often unnecessary.
See http://xml.silmaril.ie/authors/cdata/
///Peter|||I have to second Peter's sentiment about CDATA sections. CDATA sections are
meant for helping manual authoring of XML documents and should not be used
otherwise.
And no, FOR XML AUTO does not provide a way to generate CDATA sections. You
would have to use the EXPLICIT mode.
Best regards
Michael
"Peter Flynn" <peter.nosp@.m.silmaril.ie> wrote in message
news:3sahonFn6kgqU4@.individual.net...
> Toby wrote:
>
> Do you really need CDATA Sections? They are often unnecessary.
> See http://xml.silmaril.ie/authors/cdata/
> ///Peter
>

element centric XML for XML explicit - suggestion needed

my xml would be like.
<X>
-<XY>
-<XYZ>
<![CDATA[ hello adkfsd ]]>
</XYZ>
-<XYZ1>
<![CDATA[ hell adkfsd ]]>
</XYZ1>
<XY>
<XY1>
...
</XY1
</X>
it is very element centric . All the data comes from a single table.
here just for mentioning the parent tag for the datas i need to write a
select.
i wrote a query which had 6 selects and got the XML.
two of the select querys were written just to include the name for the
parent tag.
can someone pls tell me if its possible to improvise..
is it possible to use for xml auto and get CDATA..
waiting for ur replies,
toby
Toby wrote:

> my xml would be like.
> <X>
> -<XY>
> -<XYZ>
> <![CDATA[ hello adkfsd ]]>
> </XYZ>
> -<XYZ1>
> <![CDATA[ hell adkfsd ]]>
> </XYZ1>
> <XY>
> <XY1>
> ...
> </XY1
> </X>
>
> it is very element centric . All the data comes from a single table.
> here just for mentioning the parent tag for the datas i need to write a
> select.
> i wrote a query which had 6 selects and got the XML.
> two of the select querys were written just to include the name for the
> parent tag.
> can someone pls tell me if its possible to improvise..
> is it possible to use for xml auto and get CDATA..
Do you really need CDATA Sections? They are often unnecessary.
See http://xml.silmaril.ie/authors/cdata/
///Peter
|||I have to second Peter's sentiment about CDATA sections. CDATA sections are
meant for helping manual authoring of XML documents and should not be used
otherwise.
And no, FOR XML AUTO does not provide a way to generate CDATA sections. You
would have to use the EXPLICIT mode.
Best regards
Michael
"Peter Flynn" <peter.nosp@.m.silmaril.ie> wrote in message
news:3sahonFn6kgqU4@.individual.net...
> Toby wrote:
>
> Do you really need CDATA Sections? They are often unnecessary.
> See http://xml.silmaril.ie/authors/cdata/
> ///Peter
>

Sunday, February 19, 2012

efficient way to put multiple tables in one xml output

hi guys,

i'm looking for alternatives on how to put multiple tables in one xml output.

i have this .net program that has been passed to me that currently loops through some tables and calls an sp that returns a query that has a FOR XML AUTO, ELEMENTS on it, then appends <Extract> ... </Extract> as a root node for all the extracted tables then saves it as an xml file. i'm trying to optimize it by limiting the number reads to the db server, so one option is for me do the loop inside the sp.

is this efficient? any snippet? by the way, i'm using sql2k

thanks guys.

/rh4m1ll3

hi,

Bit confused with the requirement. plz let me know what you are doing exactly from the below 2 approaches:

go to one table 1 - execute sp - return xml file1 - add <Extract> ... </Extract> as root node

go to one table 2 - execute sp - return xml file2 - add <Extract> ... </Extract> as root node

go to one table 3 - execute sp - return xml file3 - add <Extract> ... </Extract> as root node

..........

( or )

go to one table1 - get some details

go to one table2 - get some details

go to one table3 - get some details

...........

pass details to sp - return xml file - add <extract> .. <extract> as root node

confirm what you are doing?

Regards,

kwaerol.

|||alright this is the current setup

here's the psuedo of the current c# app

Code Snippet


for each table.. {
x += executescalar("theSPwithForXML") //appends each result
}
x = "<Extract>" + x + "</Extract>"
// then saves x as xml file

what i'm trying to achieve is

x = executescalar("theSPthatAppendsAllTablesIntoOneXML")
// then saves x as xml file

since you cannot assign the result of a query with a FOR XML to a variable in SQL2K, i'm looking for other alternatives or workarounds in TSQL, so that "theSPthatAppendsAllTablesIntoOneXML" can return a single xml with all the tables that i need to convert.

the last resort that i'm looking at is returning multiple result instead

CREATE PROCEDURE theSPthatAppendsAllTablesIntoOneXML
AS

SELECT *
FROM Table1
FOR XML AUTO, ELEMENTS

SELECT *
FROM Table2
FOR XML AUTO, ELEMENTS

SELECT *
FROM Table3
FOR XML AUTO, ELEMENTS

-- etc etc

GO|||

Hi,

You are correct. As per my knowledge we cannot take the xml output into a local variable in sql2k.

I feel that every time u do some sql operation and get some xml output

At last want to append <extract> nodes and save that as xml file.

If I am correct. Why don't you get the resultsets at one slot from db and then make use of Load xml using XMldatadocument.

If required you can create one schema file and make use of it to load the xml data document from dataset (having multiple Tables)

Regards,

Subbu