T-SQL (SS2K8) :: How To Read First XML Node

Jun 4, 2014

its possible to check what the first node is before loading an XML file. The file name is just a combination of random numbers e.g. TMP_18028423.XML there's no way of knowing what it contains I need to check before loading into a table. Then I'll process the data from the temp table. i need to check if the first node is <Departments> then load the file that contains departments.

Here's the script I'm using to load the File:

CREATE PROCEDURE JobDepartmentXMLImport
@FileName varchar(256)
AS
BEGIN
--Create temp table
CREATE TABLE #TempDepartment(
[DepartmentName] nvarchar(64) NULL,

[code]....

View 2 Replies


ADVERTISEMENT

Read XML Node Elements Using Query

Dec 29, 2011

I am having the example xml with the data as shown below,

declare @x xml
set @x = '<SinterklaasWishlists>
<child>
<name>Tim</name>
<wishlist>
<article>
<artno>21491269</artno>

[Code] ....

I want to extract the elements of xml using sql query and insert the data into the table as shown below:

CHILDNAME ARTICLE_NUMBER DESCRIPTION PRICE
------------------ ---------------------------- ----------------------------------- -----------
Tim1 21491269 Crane 12.50
Tim1 21499517 Keyboard 10
Tim1 21521591 Crime Investigation Game 9.95
Tim2 3145678 Mouse 12.50

View 2 Replies View Related

SQL Server 2012 :: Read All Values From XML Node?

Nov 21, 2013

I have the following code and trouble reading values of Bank Accounts. If i remove the line it says "xmlns="http://applications.apch1.com/webservice/schema/" then i my query is working. But i cant remove this becasue that is what i will get response from a web service. All the records are stored in the database with this line included.

DECLARE @MyXML XML
SET @MyXML = '<GetEmployeeDetails xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<return xmlns="http://applications.apch1.com/webservice/schema/">
<CustomerID> A8339 </CustomerID>
<BankAccounts>

[Code] .....

View 2 Replies View Related

T-SQL (SS2K8) :: Select XML Node With Namespaces

Feb 15, 2012

I am trying to select data from a column that has xml data in it. I have tried all I can think of, but the results keep coming back as NULL. Not sure why but I pasted the top of the xml document so show what I am trying to do.

- <ns0:X12_00501_837_P xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006">
- <ST>
<ST01_TransactionSetIdentifierCode>837</ST01_TransactionSetIdentifierCode>
<ST02_TransactionSetControlNumber>1001</ST02_TransactionSetControlNumber>
<ST03_ImplementationGuideVersionName>005010X222A1</ST03_ImplementationGuideVersionName>
</ST>

And the query...

WITH XMLNAMESPACES('[ns0]' AS ns)
SELECT sourceclaimxml.value('(/ST01_TransactionSetIdentifierCode)[2]', 'varchar(300)') XMLValue
FROM xclaim_audit_xml
CROSS APPLY sourceclaimxml.nodes('//ST') as P(nref)
WHERE edixid='2323111'

View 9 Replies View Related

T-SQL (SS2K8) :: Fast Forward Cursors Are Read Only But Are They Insensitive

Oct 2, 2014

A fast_forward cursor is read only by definition, meaning the rows can't be updated, but I'm not sure if they are insensitive or not. Do they reflect the changes in the database after the cursor is opened?

View 6 Replies View Related

SQL 2012 :: Log Shipping - Reboot Secondary Node And Then Primary Node

Apr 20, 2015

I have not used log shipping before and find myself in a position where I need to reboot the secondary node and then the primary node and I don't actually need to failover.

Is there anything I need to be aware of. When rebooting the secondary node I assume the transactions will be held in the primary nodes log till the secondary comes back and just carry on once back up?

When rebooting the primary node nothing needs to be done and the log shipping will just start again once it has come back?

View 3 Replies View Related

Do I Need To Install SQL Server To Second Node In Cluster Prior To Adding The Node?

Jun 12, 2007

I read these instructions:

http://msdn2.microsoft.com/en-us/library/ms191545(SQL.90).aspx



But I'm not sure if I have to install SQL Server first on node 2, then add it to the cluster. Or does adding it to the cluster also install the software?



Thanks

View 1 Replies View Related

SQL 2012 :: Running 2 Distinct AGs On Each Node Of A Two Node Cluster?

Oct 23, 2014

I'm contemplating running two availability groups on a two node WSFC. The WSFC is setup with a file share witness (i.e. no shared storage). Can I safely run 1 AG on one primary node, and the other AG on the other node (as primary). Each AG would have replicas on the passive node. This would effectively allow both servers to be in use at the same time. In a failover event, I understand that both workloads would transfer to a single server - so the box needs to be sized appropriately.

View 1 Replies View Related

SQL 2012 :: 3 Node Cluster Runs With 2 Node Failures?

Jun 11, 2015

We are in the process of building a 3 node SQL Server Cluster (Server 2012/ SQL Server 2012), and we have configured the quorum so that all 3 nodes have a vote (no file share witness as we already have an odd number of nodes).

As I understand it, this should allow the cluster to run as long as 2 of the nodes remain online.

However, the validation report states that 2 node failures would be acceptable and, when we tested this by powering off two of the nodes, the cluster did indeed continue to run on a single node.

View 4 Replies View Related

Transfering Cluster Resources From One Node To Another Node

Aug 21, 2007



I configure Windows 2003 R2 and SQL 2005 two nodes Cluster. When I move cluster resource from one node to anther node it takes around 30 seconds to become online. So in that time if any query is running it stops responding.



So please suggest in this regard

View 2 Replies View Related

How Do You Determine The Active Node Inside A Stored Proc For An Active/passive 2-node Cluster?

Jan 16, 2008

I invoke xp_cmdshell proc from inside a stored procedure on a 2-node active/passive SQL 2005 SP2 Standard cluster. Depending on which server the xp_cmdshell gets executed on I need to pass different arguments in the shell command. I thought I could use host_name() function to get the runtime process server, however, I am finding that it's not behaving correctly. In one example I know my active node is server2, but the host_name() function is returning server1. The only thing that I could possible explain this is that the MSDTC cluster group is not always on the same active node as the SQL server group and in the case I am talking about the cluster groups are in this mode (differnet nodes). Does the xp_cmdshell get executed by the SQL active node or the MDTC active node? And what is the best way to find out which server is going to run my xp_cmdshell?

Thanks.

Edit:

Perhaps another by product of this is that if I run select host_name() from the Studio Management query window i get different results depending on which server I am running the Studio Management on. On server1 I get server1 and on server 2 I get server 2, all the while server2 is the active node. I need a different function that will always let me determine the correct server that'll be running the xp_cmdshell...

Edit 2: I guess I could determine the running host inside the command shell itself, but I am curious to see if i can do it (cleaner) from SQL.

View 1 Replies View Related

Transact SQL :: Making Server Database Read / Write From Read Only

Jan 12, 2012

i attached adventure works in sql server 2008 and it showing as read only ,make it read write or remove read only tag from database.

View 11 Replies View Related

SQL 2012 :: Identify Whether Files Are In Read / Write Or Read Only

Mar 24, 2015

How to identify whether the files are in read write or read only?

View 1 Replies View Related

Recovery :: Switch (Standby / Read-Only) DB To Be Read And Write

Aug 26, 2015

I'm trying to do Sharepoint DR with Log Shipping and every thing configured except one thing which is switch the WSS_Content (Standby /Read-Only) DB to be ready and Write. 

I tried from

GUI or ALTER DATABASE [WSS_Content] SET
READ_WRITE WITH NO_WAIT

but I received the below error: 

Database WSS_Content is in Warm Standby 

View 9 Replies View Related

Reset Database Files From Read-only To Read-write

Jan 18, 2008

I have two database files, one .mdf and one .ndf. The creator of these files has marked them readonly. I want to "attach" these files to a new database, but cannot do so because they are read-only. I get this message:

Server: Msg 3415, Level 16, State 2, Line 1
Database 'TestSprintLD2' is read-only or has read-only files and must be made writable before it can be upgraded.

What command(s) are needed to make these files read_write?

thanks

View 7 Replies View Related

Read Text File From SQL Server, Read Its Content, And Load It In RichTextBox (Related Component: Context.Response.BinaryWrite(), And StreamReader)

Nov 26, 2007

OBJECTIVE: I would like to read a text file from SQL Server 2000, read the text file content, and load its conntents in a RichTextBoxTHINGS I'VE DONE AND HAVE WORKING:1) I've successfully load a text file (ex: textFile.txt) in sql server database table column (with datatype Image) 2) I've also able to load the file using a Handler as below: using System;using System.Web;using System.Data.SqlClient;public class HandlerImage : IHttpHandler {string connectionString;public void ProcessRequest (HttpContext context) {connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["NWS_ScheduleSQL2000"].ConnectionString;int ImageID = Convert.ToInt32(context.Request.QueryString["id"]);SqlConnection myConnection = new SqlConnection(connectionString);string Command = "SELECT [Image], Image_Type FROM Images WHERE Image_Id=@Image_Id";SqlCommand cmd = new SqlCommand(Command, myConnection);cmd.Parameters.Add("@Image_Id", System.Data.SqlDbType.Int).Value = ImageID;SqlDataReader dr;myConnection.Open(); cmd.Prepare(); dr = cmd.ExecuteReader();if (dr.Read()){ //WRITE IMAGE TO THE BROWSERcontext.Response.ContentType = dr["Image_Type"].ToString();context.Response.BinaryWrite((byte[])dr["Image"]);}myConnection.Close();}public bool IsReusable {get {return false;}}}'>'>
<a href='<%# "HandlerDocument.ashx?id=" + Eval("Doc_ID") %>'>File
</a>- Click on this link, I'll be able to download or view the file WHAT I WANT TO DO, BUT HAVE PROBLEM:- I would like to be able to read CONTENT of this file and load it in a string as belowStreamReader SR = new StreamReader()SR = File.Open("File.txt");String contentText = SR.Readline();txtBox.text = contentText;BUT THIS ONLY WORK FOR files in the server.I would like to be able to read FILE CONTENTS from SQL Server.PLEASE HELP. I really appreciate it.

View 1 Replies View Related

SQL 2012 :: Read Committed For Read Only Database?

Jun 27, 2014

i have a database which get refreshed every day from client's data . and we need to pull heavy data from them every day as reports . so only selects happens on that database.

we do daily population of some table in some other databases from this daily refreshed DB.

will read uncommitted or NOLOCK with select queries to retrieve data faster.

there will be no dirty read as there are NO DML operation in that database so for SELECT which happens concurrently on these tables , will NOLOCK work?

View 2 Replies View Related

SQL 2012 :: Change Read-only And Read-write

Aug 15, 2014

Can a user of db owner role of a database change the databse option to read only and read-write?If not what permission I need to grant to the user?

View 1 Replies View Related

Set READ UNCOMMITTED (dirty Read) At Login.

Jul 23, 2005

Is it possible to set READ UNCOMMITTED to a user connecting to an SQL2000 server instance? I understand this can be done via a front endapplication. But what I am looking to do is to assign this to aspecific user when they login to the server via any entry application.Can this be set with a trigger?

View 1 Replies View Related

Come On SQLdatareader....read....read....read...ok Help.

Mar 12, 2004

OK, I'm using VS2003 and I'm having trouble. The page works perfectly when I created it with WebMatrix but I want to learn more about creating code behind pages and this page doesn't work. I think it has some things to do with Query builder but I can't seem to get change outside "please register". I have the table populated and it is not coming back with "login successful" or "password wrong" when I've entered correct information. Enclosed is what I've done in VS2003. Can you see where my error is? Any help would be greatly appreciated.
Thanks again.

Imports System.data.sqlclient
Imports System.Data
Public Class login2
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlCommand1 = New System.Data.SqlClient.SqlCommand
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "server=LAWORKSTATION;user id=sa;database=test;password=t3st"
'
'SqlCommand1
'
Me.SqlCommand1.CommandText = "SELECT pass FROM Customer WHERE (email = 'txtusername.text')"
Me.SqlCommand1.Connection = Me.SqlConnection1

End Sub
Protected WithEvents lblUsername As System.Web.UI.WebControls.Label
Protected WithEvents lblPassword As System.Web.UI.WebControls.Label
Protected WithEvents txtUsername As System.Web.UI.WebControls.TextBox
Protected WithEvents txtPassword As System.Web.UI.WebControls.TextBox
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
Protected WithEvents lblMessage As System.Web.UI.WebControls.Label
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Protected WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
SqlConnection1.Open()
Dim dr As SqlDataReader = SqlCommand1.ExecuteReader
If dr.Read() Then
If dr("password").ToString = txtPassword.Text Then
lblMessage.Text = "login successful"
Else
lblMessage.Text = "Wrong password"
End If
Else
lblMessage.Text = "Please register"
End If
dr.Close()
SqlConnection1.Close()
End Sub
End Class

View 8 Replies View Related

SP2 On A New Node

Dec 19, 2007

Hello,

I cannot install SP2 on a new node that was added after SP2 applied to the primary.
We had the following scenarios. Node A SP2, node B RTM.

Scenario 1) Resources moved to node A (also MSDTC and Cluster group). Setup running on node A.

Setup warns (even in log) "The product instance XXX been patched with more recent updates."
Since it sees that local instance is patched, setup don't go on. I cannot select any clusterized instance.
Scenario 2) Resources moved to node B (also MSDTC and Cluster group). Setup running on node B.

Setup logs:
12/18/2007 13:13:55.175 Exit code for passive node: XXXXA = 11203
12/18/2007 13:13:56.972 The following exception occurred: No passive nodes were successfully patched Date: 12/18/2007 13:13:56.972 File: depotsqlvaultstablesetupmainl1setupsqlsesqlsedllinstance.cpp Line: 3422
12/18/2007 13:13:57.440 Watson: Param1 = Unknown
12/18/2007 13:13:57.440 Watson: Param2 = 0x2b01
12/18/2007 13:13:57.440 Watson: Param3 = Unknown
12/18/2007 13:13:57.440 Watson: Param4 = 0x0
12/18/2007 13:13:57.440 Watson: Param5 = instance.cpp@3422
12/18/2007 13:13:57.440 Watson: Param6 = Unknown
12/18/2007 13:13:57.440 Watson: Param7 = SQL9
12/18/2007 13:13:57.440 Watson: Param8 = Hotfix@
12/18/2007 13:13:57.440 Watson: Param9 = x64
12/18/2007 13:13:57.440 Watson: Param10 = 3042

I undertstand, he cannot patch an already patched node (A). Setup stops ignoring local node. So... how can I just patch a single node (B)?

I read uninstalling Setup Support Files and reinstalling them will help faking an RTM node to the setup, but during uninstall I got the following warning "Warning 26002: The following product(s) is dependent on Microsoft SQL Server Setup Support Files (English), the key will be broken€¦" and it lists one of our instances (just one). We will test it virtually, we cannot afford loosing that instance.
Thank you!

Andrea

View 5 Replies View Related

Root Node From A FOR XML

Aug 26, 2005

Hello,

How can I get a XML with a root node from a FOR XML ?:
Now I have this:

The SQL:
SELECT * FROM Table_Projects Project
FOR XML AUTO

and the XML output:
<Project>
    <ItemID>1</ItemID>
    .....
</Project>
<Project>

    <ItemID>2</ItemID>

    .....

</Project>
...

and I want this:


<Projects>
    <Project>
        <ItemID>1</ItemID>
        .....
    </Project>
    <Project>
        <ItemID>2</ItemID>
        .....
    </Project>
    ...
</Projects>

thanks and regards,
Edu

View 5 Replies View Related

Replace The Xml Node

Oct 18, 2007

Hi ,


CREATE TABLE KUMAR (
ID INT PRIMARY KEY,
Document XML(CONTENT KUMAR))
--Document is the xmlcolumn
---------------------------------------
CREATE XML SCHEMA COLLECTION KUMAR AS
'schema file to be placed'
--KUMAR is the XML-Schema collection name
--------------------------------------------

INSERT KUMAR VALUES (1,'XML FILE TO BE PLACED')

When I try to update the xml data by using the below query

UPDATE KUMAR SET Document.modify('replace value of (/X12_U1_837/UserId) with "ABC"')

--(/X12_U1_837/UserId) Contains the XYZ,Which i need to replace with ABC
I am getting the following error
XQuery [KUMAR.Document.modify()]: The target of 'replace' must be at most one node, found 'element(UserId,#anonymous) *'

View 1 Replies View Related

They're Invading My Node!

Jul 23, 2005

We have a cluster set up at my office ( Active/Active ) that has beenpitched as some prime real-estate, apparently, as the best place in theoffice for a database. Now it looks like one of my nodes is overrun withdatabases! I'd like to set up some traces in profiler or performancemonitor to gather some stats in case we start to experience some degredationin performance. I want to be able to point to some numbers to explain to myboss why we shouldn't put so many databases on one node. Any suggestionson what are some good counters to turn on? I'm thinking I should monitorI/O wait and paging at the very least. I've also heard someone mention tomonitor page life expectancy, but I don't know much about this one.TW

View 4 Replies View Related

Xquery Return On If Node Has A Value

Sep 29, 2007

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"; (

for $p in //ACM:oproc[@id = "op1"]

return $p

)' ) FROM mytable   Thanks

View 1 Replies View Related

Sql 7 Enterprise And Node Re-building

Jul 18, 2001

Hi all,

I have a question about re-creating the sql portion on either node a or b in a clustered situation. Is it possible to do this without affecting the working node and database ? or is the best solution to make a ghosted image of the node after install is complete and if the node fails just get to a point on the affected node where you can copy the image back?

Thanks for any feedback.

P

View 1 Replies View Related

SQL 2012 :: Getting Value From XML / Node Out Of Table

May 16, 2014

I have a table which has a field with a data type of Xml. A sample record might contain something like this:

<?xml version="1.0" encoding="utf-16"?>
<order>
<Product Index="14c9643f-63d9-40c5" ProductID="13" Name="............>
<Attribute Name="Paper" OptCatId="1" Value="72" ....../>
<Attribute Name="Ink" OptCatId="2" Value="6" ......../>
<Attribute Name="Bleed" OptCatId="3" Value="15" ......./>
<Attribute Name="Number of Drops" OptCatId="0" Value="1" ...../>

I need to grab the Node/Attribute with the name of "Number of Drops" and get the value of "Value". So in this case, I simply want to get "1". How could I do this?

SELECT "value of Number of Drops"
FROM myTable
WHERE ID = ....

View 1 Replies View Related

Single Node Cluster

Dec 2, 2006

Is it possible to setup an cluster with sql server 2005 as single node cluster - and lets say in 4 month we add the second node to the cluster? - its because of budget and we do not want to setup then again.

Thanks for your help, HANNES

View 10 Replies View Related

Two Instances On Same Node In Clustering

Jan 27, 2008

Need some advice .


Our management want to have two instances of SQL Server 2005 in Clustered environment.


First instance will serve existing application and Second instance will serve their new application.


As Microsoft suggests that, its not a good practice to have multiple instance on the same node, until you have any compelling reason to have such setup. The compelling reason what the mangement have is , some time ago they used same instance for both the application. What happened was, the secondary application took all the resources from primary(main) application, and server went down( this was past.).


So, now in clustering they want to have their first instance (which will serve our existing application) with enough CPU cores & memory so that it can run smoothly and then have second instance with the remaining CPU power & memory. So ,in case if second instance tries to eats up all the resources, it can eat what it have , it cannot take resources from primary instance.


But, what my idea here is:

Initially, dont install second instance for new application( in clustering environment). Instead ,use existing servers for the upcoming new appication where production & DR is there right now ( Standalone servers).


What i mean here is: After making sure that the existing (Primary) application is comfortable in clustering environment (in PRODUCTION) , until then, run the second application on the old PROD box & old DR will serve as its DR. So ,by going in this way , we are not installing initally two instances on the same node. When the life is good for the first instance, then based on those results, we can think for the second instance.


Ii wanted to know from you guys, what you think about this. Is this idea look feasible. Please let me know.


Thanks for reading all this

View 2 Replies View Related

Trying To Add A Node To A SQL Server Cluster

Jan 31, 2008

We have been working on a project to upgrade the servers in our 2-node SQL Server environment. I evicted a node after removing it from the instance. We added the new node under a new server name. I then start the Add remove programs, choose to change the SQL 2005 environment, type the virtual server name. Choose to maintain virtual server, pick to add new node. All seems well, I enter all prompted questions, and when the install begins I get the error below.

Product: Microsoft SQL Server 2005 -- Error 1706. An installation package for the product Microsoft SQL Server 2005 cannot be found. Try the installation again using a valid copy of the installation package 'SqlRun_SQL.msi'.

So I copied the SS2K5 Enteerprise Edition software to the local C: drive, point it too the 'SqlRun_SQL.msi' in the setup folder and still get the error.

Any one experience this or have any suggestions?

View 3 Replies View Related

Transact SQL :: How To Find A Node

Nov 8, 2015

i have a table below like :
Id    ,    Request   

int     nvarchar(100)   
and in Request field i put below data :
1 <request><F3>353535</F3><F6></F6></request> 2 <request><F5>353535</F5><F6></F6></request>3 <request><F3>353535</F3><F6></F6></request>

now i need to a query that i can find records that exists <F3> and if exists , remove just the <F3> tag

 below like :
1 <request><F6></F6></request> 2 <request><F5>353535</F5><F6></F6></request>3 <request><F6></F6></request>

View 18 Replies View Related

XML Newbie: Element Vs Node

Nov 24, 2006

What is the difference between an XML "node" and an XML "element"?





TIA,



Barkingdog

View 5 Replies View Related

Remove DC From Cluster Node

Nov 9, 2006

We have:

A Microsoft cluster, (SQL Failover cluster) with one node as the domain controller. The cluster was built off site and the domain name used is the same as our existing domain where we eventually need to install this cluster.

We need: (At least I think we need:)

To remove node 2 from the "cluster domain", DCPROMO node 1 and eliminate the "cluster domain". We then need to join the cluster (nodes) to the existing domain. We also need to recreate the accounts and groups used during installation.

Questions:

1) What will happen to the "domain accounts" used when installing SQL2005? (Other than they will go away. I mean what adverse impact will that have on the installation?)

2) Will I have to re-install SQL 2005?

3) Is my paranoia real or imagined? (Will Elvis live?)

Any prior experience with this would be greatly appreciated. In fact, a WAG is appreciated too.



Regards,

Mike

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved