Click here to Skip to main content
15,914,444 members
Home / Discussions / Database
   

Database

 
GeneralRe: A question about design Relational Model Pin
SilimSayo11-May-11 10:07
SilimSayo11-May-11 10:07 
GeneralRe: A question about design Relational Model Pin
Eddy Vluggen11-May-11 10:18
professionalEddy Vluggen11-May-11 10:18 
GeneralRe: A question about design Relational Model Pin
SilimSayo11-May-11 12:49
SilimSayo11-May-11 12:49 
AnswerRe: A question about design Relational Model Pin
Shameel5-Apr-11 5:32
professionalShameel5-Apr-11 5:32 
GeneralRe: A question about design Relational Model Pin
Klaus-Werner Konrad13-Apr-11 12:49
Klaus-Werner Konrad13-Apr-11 12:49 
QuestionConnection string for database on another comouter Pin
wjbjnr2-Apr-11 21:54
wjbjnr2-Apr-11 21:54 
AnswerRe: Connection string for database on another comouter Pin
Wendelius2-Apr-11 22:30
mentorWendelius2-Apr-11 22:30 
GeneralRe: Connection string for database on another comouter Pin
wjbjnr3-Apr-11 5:08
wjbjnr3-Apr-11 5:08 
GeneralRe: Connection string for database on another comouter Pin
Wendelius3-Apr-11 5:57
mentorWendelius3-Apr-11 5:57 
GeneralRe: Connection string for database on another comouter Pin
wjbjnr3-Apr-11 7:01
wjbjnr3-Apr-11 7:01 
GeneralRe: Connection string for database on another comouter Pin
Wendelius3-Apr-11 7:15
mentorWendelius3-Apr-11 7:15 
GeneralRe: Connection string for database on another comouter Pin
wjbjnr3-Apr-11 7:43
wjbjnr3-Apr-11 7:43 
GeneralRe: Connection string for database on another comouter Pin
Wendelius3-Apr-11 7:53
mentorWendelius3-Apr-11 7:53 
GeneralRe: Connection string for database on another comouter Pin
wjbjnr3-Apr-11 8:22
wjbjnr3-Apr-11 8:22 
GeneralRe: Connection string for database on another comouter Pin
Wendelius3-Apr-11 9:33
mentorWendelius3-Apr-11 9:33 
QuestionSQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
T21021-Apr-11 3:58
T21021-Apr-11 3:58 
AnswerRe: SQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
Wendelius1-Apr-11 6:42
mentorWendelius1-Apr-11 6:42 
GeneralRe: SQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
T21021-Apr-11 16:04
T21021-Apr-11 16:04 
GeneralRe: SQL Server Query Transportation Time Based on Latency and Internet Download Speed Pin
Wendelius1-Apr-11 20:43
mentorWendelius1-Apr-11 20:43 
Questioninvalid parameter value on CreateSubscription Pin
run4ever_771-Apr-11 2:40
run4ever_771-Apr-11 2:40 
QuestionHarmless joke or mean prank Pin
shelbypowell1-Apr-11 1:14
shelbypowell1-Apr-11 1:14 
QuestionSelecting from an XML datatype into a table Pin
Mel Padden31-Mar-11 23:47
Mel Padden31-Mar-11 23:47 
Hi all.

I'm trying to use an XML datatype to pass around tabular data between functions, and I'm a bit unfamiliar with both this and XQuery syntax, so this is troublesome for me.

I have a piece of code like so:

DECLARE	@time_series	XML;
SET @time_series = 
	'<timeSeries>
		<ts><date>2010-06-30</date><value>1.235648</value></ts>
		<ts><date>2010-07-31</date><value>564654.235648</value></ts>
		<ts><date>2010-08-31</date><value>5465465.235648</value></ts>
		<ts><date>2010-09-30</date><value>952031.235648</value></ts>
	</timeSeries>'
;

DECLARE @tbl_time_series	TABLE(
	ts_date			DATETIME
,	ts_value		FLOAT
);

INSERT INTO @tbl_time_series
SELECT		
		TS.item.nodes('/date').value('.', 'datetime')	AS tsdate
	,	TS.item.nodes('/value').value('.', 'float')		AS tsvalue
FROM		
	@time_series.nodes('timeSeries/ts') AS TS(item)
;


"item", by my reasoning, should allow me to select the date node underneath it in the select, but it appears not.
I get this message:

Msg 227, Level 15, State 1, Line 19
"nodes" is not a valid function, property, or field.


All I want is to end up with a table like this;

ts_date     ts_value
----------  --------------
2010-06-30  1.235648
2010-07-31  564654.235648
2010-08-31  5465465.235648
2010-09-30  952031.235648


when I try this:

INSERT INTO @tbl_time_series
SELECT		
		TS.item.query('/date').value('.', 'datetime')	AS tsdate
	,	TS.item.query('/value').value('.', 'float')		AS tsvalue
FROM		
	@time_series.nodes('timeSeries/ts') AS TS(item)
;


See the query in the select statement instead of the node? this runs alright, but I get a result set like this:

1900-01-01 00:00:00.000	0
1900-01-01 00:00:00.000	0
1900-01-01 00:00:00.000	0
1900-01-01 00:00:00.000	0


I think I'm nearly there but my XQuery noobiness is failing me... Sniff | :^) Sniff | :^)


Any suggestions?
Smokie, this is not 'Nam. This is bowling. There are rules.
www.geticeberg.com

AnswerRe: Selecting from an XML datatype into a table Pin
Mel Padden1-Apr-11 0:01
Mel Padden1-Apr-11 0:01 
QuestionSQL question Pin
loyal ginger31-Mar-11 8:14
loyal ginger31-Mar-11 8:14 
QuestionRe: SQL question Pin
Jörgen Andersson31-Mar-11 8:45
professionalJörgen Andersson31-Mar-11 8:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.