Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends...

i have a xml document and i want to load data from that xml document into new table created based on that document. That's why i have written following query but it throws an error

SQL
 select * into t from
(SELECT 10, xCol
FROM    (SELECT *
    FROM OPENROWSET (BULK 'C:\Users\TAUSEEF\Desktop\test.xml', SINGLE_CLOB)
 AS xCol) AS R(xCol))



Error:

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near ')'.


Please help me
Posted

Try to use this,

SQL
select * into t from
(SELECT 10, xCol
FROM    (SELECT *
    FROM OPENROWSET (BULK 'C:\Users\TAUSEEF\Desktop\test.xml', SINGLE_CLOB)
 AS xCol) AS R(xCol)) a
 
Share this answer
 
Comments
TAUSEEF KALDANE 26-Aug-15 7:05am    
No Sir, i tried ur query and it is also throwing errors as follows
1. Msg 8155, Level 16, State 2, Line 5
No column name was specified for column 1 of 'a'.

2. Msg 1038, Level 15, State 5, Line 1
An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.
deepankarbhatnagar 26-Aug-15 7:11am    
OK let me check again.
Hi TAUSEEF,

In addition to the answer of deepankarbhatnagar,

Please try with below query. In the inner query, column name should be there for the column value 10.


SQL
select * into t from
(SELECT 10 as Col1, xCol
FROM    (SELECT *
    FROM OPENROWSET (BULK 'C:\Users\TAUSEEF\Desktop\test.xml', SINGLE_CLOB)
 AS xCol) AS R(xCol)) a



Please let me know if you have any concern or query on this or if you are facing any other issue.

Thanks
 
Share this answer
 
Comments
TAUSEEF KALDANE 26-Aug-15 7:37am    
Sir, it works. Thank you sir
Advay Pandya 26-Aug-15 7:44am    
Welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900