June 11, 2012 at 7:52 am
Hi All,
Im trying to create a FOR XML statement to export each row individually in my database into an individual XML file.
Everytime i run the query i get the following error:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "dbo.payloads.ContentReference" could not be bound.
Msg 4104, Level 16, State 1, Line 7
The multi-part identifier "dbo.payloads.Id" could not be bound.
My code is below:
SELECT (Select dbo.payloads.ContentReference as ImportFileName
FOR
XML PATH ('FileInfo'),
TYPE
),
(Select 'PS-SCR/1' as ParentReference,
dbo.payloads.Id as UniqueID,
'' as Folder,
'False' as RegisterAsRecord,
'OLMMailMerge' as DocumentType
FOR
XML PATH ('Release'),
TYPE
)
FOR
XML PATH (''),
ROOT('XmlMetadataProcess')
GO
Any ideas?
Regards
Brendan
June 11, 2012 at 8:06 am
Neither ContentReference nor ID are defined column aliases.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 11, 2012 at 8:12 am
Do i need to?
Dbo.Payloads is the table?
Sorry im new to this!
Regards
Brendan
June 11, 2012 at 8:16 am
you cannot refernece a column without saying what table it comes from...looks like you need "FROM dbo.payloads"
ie:
...Select dbo.payloads.ContentReference as ImportFileName
FROM dbo.payloads
FOR
XML PATH ('FileInfo'),
TYPE...
maybe like this:
SELECT (Select dbo.payloads.ContentReference as ImportFileName
FROM dbo.payloads
FOR
XML PATH ('FileInfo'),
TYPE
),
(Select 'PS-SCR/1' as ParentReference,
dbo.payloads.Id as UniqueID,
'' as Folder,
'False' as RegisterAsRecord,
'OLMMailMerge' as DocumentType
FROM dbo.payloads
FOR
XML PATH ('Release'),
TYPE
)
FOR
XML PATH (''),
ROOT('XmlMetadataProcess')
GO
Lowell
June 11, 2012 at 8:21 am
Fantastic thats worked, your a star! Pardon my ignorance!
The only thing thats happening is that its creating a giant XML file with all the rows in, what i want it to do is create an XML file for each row.
How do i modify my query for that to happen?
Thanks in advance, its much appreciated
Regards
Brendan
June 11, 2012 at 8:25 am
brendan.tate (6/11/2012)
Do i need to?
Sure, otherwise how does SQL know what you mean
Dbo.Payloads is the table?
Maybe, but you haven't got any FROM clause, so again, how does SQL know what you mean?
The format for a SELECT is
SELECT <columns>
FROM <table>
The only time you can omit the FROM is when you're selecting constants, like SELECT getdate() as CurrentDate.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply