Monday, March 26, 2012
How create XMLSXHEMA with FOR XML EXPLICIT
i have this query:
SELECT 1 as Tag, NULL as Parent,
nomecampo as [label!1!for],
etichetta as [label!1!],
null as [input!2!id],
null as [input!2!type],
null as [input!2!name],
null as [input!2!value]
FROM t_campiaree
UNION ALL
select 2 as tag,
0 as parent,
null as [label!2!for],
null as [label!2!],
id as [input!2!id],
tipointerfaccia as [input!2!type],
nomecampo as [input!2!name],
(seleas [input!2!value]
from t_campiaree
FOR XML EXPLICIT
and the results is this:
<label for=3D"nome">Nome</label>
<label for=3D"cognome">Cognome</label>
<label for=3D"eta">Et=E0</label>
<input id=3D"1" type=3D"input" name=3D"nome" value=3D"" />
<input id=3D"2" type=3D"input" name=3D"cognome" value=3D"" />
<input id=3D"3" type=3D"input" name=3D"eta" value=3D"" />
now, how i can create schema for this xml file?
the XMLSCHEMA option don't work with EXPLICIT mode right?
Since you already know the structure that you want, best is to create your
XML Schema a priori using for example the VisualStudio schema designer. You
can even use an example document to infer much of the schema structure...
Best regards
Michael
"maurox" <mrago@.inwind.it> wrote in message
news:1141917666.744839.229840@.j33g2000cwa.googlegr oups.com...
Hi,
i have this query:
SELECT 1 as Tag, NULL as Parent,
nomecampo as [label!1!for],
etichetta as [label!1!],
null as [input!2!id],
null as [input!2!type],
null as [input!2!name],
null as [input!2!value]
FROM t_campiaree
UNION ALL
select 2 as tag,
0 as parent,
null as [label!2!for],
null as [label!2!],
id as [input!2!id],
tipointerfaccia as [input!2!type],
nomecampo as [input!2!name],
(seleas [input!2!value]
from t_campiaree
FOR XML EXPLICIT
and the results is this:
<label for="nome">Nome</label>
<label for="cognome">Cognome</label>
<label for="eta">Et</label>
<input id="1" type="input" name="nome" value="" />
<input id="2" type="input" name="cognome" value="" />
<input id="3" type="input" name="eta" value="" />
now, how i can create schema for this xml file?
the XMLSCHEMA option don't work with EXPLICIT mode right?
sql
How create XMLSXHEMA with FOR XML EXPLICIT
i have this query:
SELECT 1 as Tag, NULL as Parent,
nomecampo as [label!1!for],
etichetta as [label!1!],
null as [input!2!id],
null as [input!2!type],
null as [input!2!name],
null as [input!2!value]
FROM t_campiaree
UNION ALL
select 2 as tag,
0 as parent,
null as [label!2!for],
null as [label!2!],
id as [input!2!id],
tipointerfaccia as [input!2!type],
nomecampo as [input!2!name],
(seleas [input!2!value]
from t_campiaree
FOR XML EXPLICIT
and the results is this:
<label for=3D"nome">Nome</label>
<label for=3D"cognome">Cognome</label>
<label for=3D"eta">Et=E0</label>
<input id=3D"1" type=3D"input" name=3D"nome" value=3D"" />
<input id=3D"2" type=3D"input" name=3D"cognome" value=3D"" />
<input id=3D"3" type=3D"input" name=3D"eta" value=3D"" />
now, how i can create schema for this xml file?
the XMLSCHEMA option don't work with EXPLICIT mode right?Since you already know the structure that you want, best is to create your
XML Schema a priori using for example the VisualStudio schema designer. You
can even use an example document to infer much of the schema structure...
Best regards
Michael
"maurox" <mrago@.inwind.it> wrote in message
news:1141917666.744839.229840@.j33g2000cwa.googlegroups.com...
Hi,
i have this query:
SELECT 1 as Tag, NULL as Parent,
nomecampo as [label!1!for],
etichetta as [label!1!],
null as [input!2!id],
null as [input!2!type],
null as [input!2!name],
null as [input!2!value]
FROM t_campiaree
UNION ALL
select 2 as tag,
0 as parent,
null as [label!2!for],
null as [label!2!],
id as [input!2!id],
tipointerfaccia as [input!2!type],
nomecampo as [input!2!name],
(seleas [input!2!value]
from t_campiaree
FOR XML EXPLICIT
and the results is this:
<label for="nome">Nome</label>
<label for="cognome">Cognome</label>
<label for="eta">Et</label>
<input id="1" type="input" name="nome" value="" />
<input id="2" type="input" name="cognome" value="" />
<input id="3" type="input" name="eta" value="" />
now, how i can create schema for this xml file?
the XMLSCHEMA option don't work with EXPLICIT mode right?
Friday, March 23, 2012
How could I assign rank.
select [FI NAME], round (sum(FIWORKING.GROSPFT), 0)as FIGROSS from from FIWORKING
where FIWORKING.[FI NAME] IS NOT NULL
group by FIWORKING.[FI NAME]
order by sum (FIWORKING."GROSPFT") DESC
Which returns below
name1 65784
name2 32586
name3 37892
based on this, I would like to be able to set a rank (aka 1 , 2 , 3, etc)
for NAME1, NAME2, etc
I would like to store this in table GROSPFTRANK
That Table looks like
name1 1
name2 2
I haven't been able to figure out the SQL to do this.
Thanks for an help
ChrisYou can create a table with an identity column. Insert into that table using your query and the ranking will automatically be applied.|||There are several ways to skin this cat.
One method is to make the second field in your destination table an incrementing identity column, and then just insert your ordered data into it.
A second method would be to create a temporary table with an autoincrement column and load your data into it prior to storing it in your permanent table.
Or you could use this sql statement, which runs two totals and then counts the number of records in the second set which are less than the value in the first set:
Insert into GROSPFTRANK ([FI NAME], [RANK])
select [FIWORKINGOUTER].[FI NAME], count([FIGROSS].[FI NAME])
from
(select [FI NAME], round(sum(FIWORKING.GROSPFT), 0)as FIGROSS
from FIWORKING
where FIWORKING.[FI NAME] IS NOT NULL
group by FIWORKING.[FI NAME]) FIWORKINGOUTER
inner join
(select [FI NAME], round(sum(FIWORKING.GROSPFT), 0)as FIGROSS
from FIWORKING
where FIWORKING.[FI NAME] IS NOT NULL
group by FIWORKING.[FI NAME]) FIWORKINGSUB
on (FIWORKINGOUTER.FIGROSS < FIWORKINGSUB.FIGROSS)
Note that this assigns two [FI NAME] values the same rank if they have the same summary value. If you want unique ranks based on, say, the alphabetical order of [FI NAME], join the two subqueries with this ON statement:
on (FIWORKINGOUTER.FIGROSS < FIWORKINGSUB.FIGROSS)
or (FIWORKINGOUTER.FIGROSS = FIWORKINGSUB.FIGROSS
and [FIWORKINGOUTER].[FI NAME] < [FIWORKINGSUB].[FI NAME])
blindman
Wednesday, March 7, 2012
How can I workaround this problem?
Hello everbody,
this query:
SELECT * FROM TBL_DEVICE_DRIVERS
WHERE (DD_CATEGORIES & 2147483648) > 0
bring the error message:
Invalid operator for data type.
The value 2147483648 is hex 0x80000000 for bitwise
joining defined.
I try to cast it to decimal, but it does not work.
Have anybody an idea?
Thanks for answers!
hi,
what is the datatype of DD_CATEGORIES column? The bitwise operator works only on int datatypes hence the Invalid Operator for DataType.
ADD'L:
I think what happens is an overflow of the datatype : 2147483648 (max int), so cast the constant (2147483648) to bigint ex:
SELECT someCol & CAST(2147483648 AS BIGINT)
HTH|||
Will you please elaborate what you want to achive? as far as i understand you are try to make logical AND operation in the where clause as "DD_CATEGORIES & 2147483648".
what type of DD_CATRGORIES is ? try to check it data type
OR send the table structure & some semple data to, so that we can check it.
Gurpreet S. Gill
|||Thomas:
Good question! Look at this:
-- -
-- Representation problem with 0x80000000
--
-- Even though 0x80000000 is a valid integer representation of -2147483648, MS SQL Server does
-- not seem to interpret this constant as an integer.
--
-- 1. The datalength of -2147483648 is 5; this is clearly not an INTEGER representation.
-- 2. When the "constant" -2147483648 is converted to binary its representation is 0x0A00000000
-- and NOT 0x80000000.
-- 3. If -2147483648 is cast as an integer, it then takes on the 0x80000000 representation.
-- 4. When -2147483648 is cast as an integer it can now be operated on by the & operator.
--
-- Not what you expected is it!
-- -
select datalength ( -2147483648) as ResultsResults
--
5
select convert (binary(5), -2147483648) as ResultsResults
0x0A00000000
select convert (binary(4), cast(-2147483648 as int)) as results
results
-
0x80000000
select convert (binary (4), cast(-2147483648 as int) & cast(-2147483648 as int)) as ResultsResults
-
0x80000000
Dave