I was given a 2 GB XML file without an XSD. I need to find the element names. I know how to do that using openxml but it takes forever on a file this large. Is there a faster way to do it using xquery?
this is sanjeev, i have SSIS package, using my c# program i want to add one execute package task to this package's sequence container.
it is creating the new package with out any probelm. but when i opened the package and try to move the newly created exeute package task it is giving the following error.
the element cannot be found in a collection. this error happens when you try to retrieve an element from a collection on a container during the execution of the package
i have a data base sql Server .I wrote a stored procedure or attach my database but it is attached in read only mode how can remove read-only.
this is my stored procedure.
create procedure attache as declare @trouvemdf int declare @trouveldf int if exists (select name from sysdatabases where name='Gestion_Parc')
[Code] ....
i try this EXEC sp_dboption 'Gestion_Parc', 'read only', 'FALSE' but it causes those error
Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "C: Gestion_Parc.mdf". Operating system error 5: "5 (Access is denied.)". Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "C: Gestion_Parc_log.ldf". Operating system error 5: "5 (Access is denied.)". Msg 945, Level 14, State 2, Line 1
I am reading text file using OPENROWSET command. The read is successful. But the UNICODE characters in the file is not showing properly in the output.I am using a sql like below:
select * FROM OPENROWSET('MICROSOFT.ACE.OLEDB.12.0','Text;Database=ppa20-igloo-fsMODELSTORECR106_GIM_UKGISourceFilesProcess;HDR=Yes;Format=Delimited(|)', 'SELECT * FROM [RUW_P_Reinsurers_Aviva_and_Others_Map.txt]')
how should I read the unicode characters correctly.
a. Read data from Different CSV files. b. insert and update data to Data base in multiple table using joins.
This execution runs for 1-2 hours.I can use C# with Ado.net, but only concern I see is if in between execution fails due to some connection or other error. All insert data has to be cleaned up again.I feel writing and Store procedure inside transaction, which will take path's for CSV file as input and insert data in database. using transaction we will have flexibility rollback to original state.
I need a solution (script) where I can pull all objects(DB's incudes tables, views, synonyms, stored procedures, primary key, foreign key, triggers etc) definitions from the server in a dependency order. I want to generate a script from these objects, where if I run script all objects should be created the way it is..
.All dependencies should be automatically available in script in a dependency order. What is the best way to bring all objects (definition) in form of scripts.
These are the fields am looking - databsename, schemaname, objectname, typeofobject, depenedencyorder (nothing but level)...
Does anyone know why this works: SELECT [MyXmlColumn].query('/root') FROM [MyDatabase].[dbo].[MyTable] But this produces an error: SELECT [MyDatabase].[dbo].[MyTable].[MyXmlColumn].query('/root') FROM [MyDatabase].[dbo].[MyTable]
System.Data.SqlClient.SqlException: Invalid column name 'MyXmlColumn'.
I have the following XML in an XML column in a SQL 2005 Database.<DeliveryList xmlns="http://schemas.adventure-works.com/DeliverySchedule"><Delivery SalesOrderID="43659"><CustomerName>Steve Schmidt</CustomerName><Address>6126 North Sixth Street, Rockhampton</Address></Delivery><Delivery SalesOrderID="43660"><CustomerName>Tony Lopez</CustomerName><Address>6445 Cashew Street, Rockhampton</Address></Delivery></DeliveryList>I need to query that column using the value method to retreive the addressof the first delivery. I come up with this,SELECTDeliveryList.value('data((/DeliveryList/Delivery/Address)[1])','nvarchar(100)')DeliveryAddressFROM Sales.DeliverySchedulebut it tells meXQuery [Sales.DeliverySchedule.DeliveryList.value()]: There is no elementnamed 'DeliveryList'I have tried every permutation of the path and I can not seem to get it towork? Any ideas?
Hi,I am using xquery to extract XML fragments from my database. How do I xquery a table containing XML (typed) and return only nodes that meet the xquery.For example, the following returns empty cells if there is not @id = "op1". How I I only return values and not empty cells? SELECT xmldata.query('declare namespace ACM="www.mydomain.com"; (
I am trying to query data in an XML variable and I am having troublegetting the data out in the format that I would like. Given thefollowing XML:declare @myDoc xmlset @myDoc = '<OwnershipTeamGuid="23EA393A-3926-4A55-8329-FE747593379D" TeamName=".NETFramework"><Roles><Role Guid="93BDB4E2-95A0-438D-96E4-43032EB2BA16" Name="API ReviewPM Contact" ContactAlias="John.Smith" Inherited="0" ArtifactName="" /><Role Guid="8A7145EF-B48B-4A93-BFA5-28B53995C022" Name="Architect"ContactAlias="John.Doe" Inherited="0" ArtifactName="" /><Role Guid="BF727283-B18C-415A-A38C-CEC15CD341D9" Name="Corp VP"ContactAlias="None" Inherited="0" ArtifactName="" /></Roles></Ownership>'What I would like to do is run an XQuery against the variable and getattribute data back in normal rows and columns like the following:Guid NameContactAlias------------------------------------ ---------------------------------93BDB4E2-95A0-438D-96E4-43032EB2BA16 API Review PM Contact John.Smith8A7145EF-B48B-4A93-BFA5-28B53995C022 Architect John.DoeBF727283-B18C-415A-A38C-CEC15CD341D9 Corp VP NoneI've checked the Query and Value methods and have not been able to getthem to do this for me. Is this even possible w/XQuery? Do I need touse OpenXML to do what I am trying to accomplish?Thanks for your help!
This querySELECT DeliveryList.query('declare default element namespacehttp://schemas.adventure-works.com/DeliverySchedule;<DeliveryRoute><RouteNo>{ sql:column("D.DeliveryRoute") }</RouteNo>for a$ in /DeliveryList/Delivery/Addressreturn<Address>a$</Address></DeliveryRoute>')as ResultFROM Sales.DeliverySchedule DReturns this XML<DeliveryRoute xmlns="http://schemas.adventure-works.com/DeliverySchedule"><RouteNo>3</RouteNo>for a$ in /DeliveryList/Delivery/Addressreturn<Address>a$</Address></DeliveryRoute>I need it to return this XML<DeliveryRoute xmlns="http://schemas.adventure-works.com/DeliverySchedule><RouteNo<3>/RouteNo><Address>6126 North Sixth Street, Rockhampton</Address><Address>6445 Cashew Street, Rockhampton</Address></DeiveryRoute>What am I doing wrong? Any ideas? All help is appreciated.TIA, ~CK
UPDATE Sales.DeliveryScheduleSET DeliveryList.modify('declare namespacedf=http://schemas.adventure-works.com/DeliverySchedule;replace value of (df:DeliveryList/df:Delivery/df:Address)[1]' with "7194Fourth St., Rockhampton"')WHERE Sales.DeliverySchedule.ScheduleID = 1This query gives me the following errorXQuery [Sales.DeliverySchedule.DeliveryList.modify()]: Invalid sourcecharacter 0x2019Any ideas? What am I doing wrong here? Thanks for any advice.TIA,~CK
Im using the Xquery:SELECT @xmlDoc.query(' for $item in (/Collection/Content) where $item/Html/root/DocInfo/Webinar = "White Paper" order by $item[1]/Html[1]/root[1]/DocInfo[1]/Title[1] ascending return $item '); I only want to return the TOP 5 nodes (not the entire nodelist). What is the FLOWR expression or simplest way to return the limited nodeset? Thanks
I am trying to learn XQuery and Xpath in SQL Server. I created a sample file and uploaded it to a Table with 2 columns ID, XMLDoc. The below code is within the document in the XMLDoc column so it is the only record in the column.
I am trying to query the file so it will show all the results in a table like a normal select statement would. How would you construct the select statement to select all the information like a select * ? How would you select one field like all suppliers? I would like to select the supplier, requestor for each item.
Hi,does anyone kown if the final release or one of the next Betas ofSQL-Server 2005 will support XQuery-Statemets including the LET-Feature.Thanks,Tobias
Hi,I haev the following code:DECLARE @x xmlSET @x='<Root><row id="1"><name>Larry</name><oflw>some text</oflw></row><row id="2"><name>Joe</name></row><row id="3" /></Root>'exec sp_xml_preparedocument @idoc OUTPUT, @xSELECT * FROM OPENXML(@idoc, '/Root')This gives the following detailsidparentidnodetype localnameprefixnamespaceuridatatypeprev textI want to get the same details using XQuery, please let me know how togo about it.Regards,Shilpa
I want to evaluate a math formula inside of a function, so I can't use dynamic SQL.
I found that the query on an XML-variable with a literal works well.
DECLARE @sParsedFormula varchar(200); DECLARE @xFormula xml; SET @xFormula = ''; SET @sParsedFormula = '1+2'; SELECT @xFormula.query('3+3') , @xFormula.query('sql:variable("@sParsedFormula")')Output (1st value is correctly evaluated, 2nd not): "6", "1+2"
I can't directly pass @sParsedFormula to the query otherwise I get "The argument 1 of the XML data type method "query" must be a string literal". What is the correct XQuery-syntax to evaluate the SQL:variable?
I am trying to use xquery to get event data back from extended events. I am trying to use some sample data from Grant Fritchey but I am getting null records back. Below is the xml - I just want to retrieve a distinct list of the client_hostname and client_app_name.
WITH xEvents AS (SELECT object_name AS xEventName, CAST (event_data AS xml) AS xEventData FROM sys.fn_xe_file_target_read_file ('C:LoginTraceShared_0*.xel', NULL, NULL, NULL)) SELECT distinct top 1000 xEventName, xEventData.value('(/event/data[@action_name=''Client_APP_Name'']/value)[1]','varchar') Client_APP_Name, xEventData.value('(/event/data[@action_name=''Client_Host_Name'']/value)[1]','varchar') Client_Host_Name FROM xEvents
Hello all,I'm trying to generate some XML directly from MS SQL with thefollowing codeSELECT1 AS tag, NULL AS parent, NULL AS [GoogleCustomizations!1], NULL AS [Annotations!2], NULL AS [Annotation!3], NULL AS [Annotation!3!about], NULL AS [Annotation!3!score], NULL AS [Label!4], NULL AS [Label!4!name]UNIONSELECT2 AS tag, 1 AS parent, NULL, NULL, NULL, NULL, NULL, NULL, NULLUNIONSELECTTOP 503 AS tag, 2 AS parent, NULL, NULL, NULL, 'www.' + domainName, 1 -- score, NULL, NULLFROM tbl_auDomainNameUNIONSELECT4 AS tag, 3 AS parent, NULL, NULL, NULL, NULL, NULL, NULL, '_cse_ad-o6lgdody'FOR XML EXPLICITThe XML it needs to create is as following<GoogleCustomizations><Annotations><Annotation about="www.clickfind.com.au/*" score="1"><Label name="_cse_ad-o6lgdody" /></Annotation><Annotation about="www.lookle.com/*" score="1"><Label name="_cse_ad-o6lgdody" /></Annotation><Annotation about="www.sensis.com.au/*" score="1"><Label name="_cse_ad-o6lgdody" /></Annotation></Annotations></GoogleCustomizations>It is currently creating<GoogleCustomizations><Annotations><Annotation about="www.10000steps.org.au" score="1" /><Annotation about="www.101fm.asn.au" score="1" /><Annotation about="www.aao.gov.au" score="1"><Label name="_cse_ad-o6lgdody" /></Annotation></Annotations></GoogleCustomizations>I cannot get my head around how I can get the label <Labelname="_cse_ad-o6lgdody" />in each element. Does anyone know?Thanks in advance.