Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Wednesday, March 21, 2012

Posting to SQLXML

Hi,
I'm new to SQLXML and have run into a problem when using it
to update SQL tables from our application database.
We are generating XML in our application db and http
posting it to update an SQL database. The
(attribute-centric) XML generated matches the target table,
the element name is the same as the table name and the
attributes match the columns to be updated.
<ROOT>
<SUPPINV TABLE_KEY="10542049*202.12" INVOICE_TOTAL="377.56"
INVOICE_NUMBER="124577" INVOICE_DATE_KEY="12475">
<SUPPINV TABLE_KEY="123 ... >
</ROOT>
We have to URLEncode the XML then using HTTP post, we post
directly to the SQLXML URL from the application db.
This works as long as the size of posted data does not
exceed about 35kb and is not between 4 & 8Kb. This means I
have to chunk the XML into about 40 rows per post.
Also after posting about 100,000 rows (at 40 per time) or
so I generally get an HTTP 500 error.
Can anyone explain what is going on here and perhaps
suggest a way to improve this.
Regards,
StuartDid you limit the post size in SqlXml? What about the timeout in IIS?
Could be the request is just taking too long and timing out...
Irwin
"Stuart" <newplanet_x@.yahoo.com.au> wrote in message
news:1cf801c50fe8$3fea0da0$a601280a@.phx.gbl...
> Hi,
> I'm new to SQLXML and have run into a problem when using it
> to update SQL tables from our application database.
> We are generating XML in our application db and http
> posting it to update an SQL database. The
> (attribute-centric) XML generated matches the target table,
> the element name is the same as the table name and the
> attributes match the columns to be updated.
> <ROOT>
> <SUPPINV TABLE_KEY="10542049*202.12" INVOICE_TOTAL="377.56"
> INVOICE_NUMBER="124577" INVOICE_DATE_KEY="12475">
> <SUPPINV TABLE_KEY="123 ... >
> </ROOT>
> We have to URLEncode the XML then using HTTP post, we post
> directly to the SQLXML URL from the application db.
> This works as long as the size of posted data does not
> exceed about 35kb and is not between 4 & 8Kb. This means I
> have to chunk the XML into about 40 rows per post.
> Also after posting about 100,000 rows (at 40 per time) or
> so I generally get an HTTP 500 error.
> Can anyone explain what is going on here and perhaps
> suggest a way to improve this.
> Regards,
> Stuartsql

Posting to SQLXML

Hi,
I'm new to SQLXML and have run into a problem when using it
to update SQL tables from our application database.
We are generating XML in our application db and http
posting it to update an SQL database. The
(attribute-centric) XML generated matches the target table,
the element name is the same as the table name and the
attributes match the columns to be updated.
<ROOT>
<SUPPINV TABLE_KEY="10542049*202.12" INVOICE_TOTAL="377.56"
INVOICE_NUMBER="124577" INVOICE_DATE_KEY="12475">
<SUPPINV TABLE_KEY="123 ... >
</ROOT>
We have to URLEncode the XML then using HTTP post, we post
directly to the SQLXML URL from the application db.
This works as long as the size of posted data does not
exceed about 35kb and is not between 4 & 8Kb. This means I
have to chunk the XML into about 40 rows per post.
Also after posting about 100,000 rows (at 40 per time) or
so I generally get an HTTP 500 error.
Can anyone explain what is going on here and perhaps
suggest a way to improve this.
Regards,
Stuart
Did you limit the post size in SqlXml? What about the timeout in IIS?
Could be the request is just taking too long and timing out...
Irwin
"Stuart" <newplanet_x@.yahoo.com.au> wrote in message
news:1cf801c50fe8$3fea0da0$a601280a@.phx.gbl...
> Hi,
> I'm new to SQLXML and have run into a problem when using it
> to update SQL tables from our application database.
> We are generating XML in our application db and http
> posting it to update an SQL database. The
> (attribute-centric) XML generated matches the target table,
> the element name is the same as the table name and the
> attributes match the columns to be updated.
> <ROOT>
> <SUPPINV TABLE_KEY="10542049*202.12" INVOICE_TOTAL="377.56"
> INVOICE_NUMBER="124577" INVOICE_DATE_KEY="12475">
> <SUPPINV TABLE_KEY="123 ... >
> </ROOT>
> We have to URLEncode the XML then using HTTP post, we post
> directly to the SQLXML URL from the application db.
> This works as long as the size of posted data does not
> exceed about 35kb and is not between 4 & 8Kb. This means I
> have to chunk the XML into about 40 rows per post.
> Also after posting about 100,000 rows (at 40 per time) or
> so I generally get an HTTP 500 error.
> Can anyone explain what is going on here and perhaps
> suggest a way to improve this.
> Regards,
> Stuart

Post update for SQLServer SP2--is there one for SQLServer Express?

Regarding KB935356, is there a "post" service pack 2 update for SQLServer Express?

Thanks.

hi,

LizWard wrote:

Regarding KB935356, is there a "post" service pack 2 update for SQLServer Express?

Thanks.

I'm currently at 3159 build (both on SQL Server 2005 Dev editions and SQLEpxress), so I did not install 3161, but the "Applies to" section reports SQLExpress and SQLExpress With Advanced Services as well, so you should be able to install it on them, as long as you really need them and contact Microsoft for it..

regards

|||For SQLExpress, you stated that you are currently on build 3159. Where did you get that build from? I'm currently on this version:

9.00.3042.00.

I downloaded what seemed to be the latest SQLExpress...please send the URL that you used.

Thanks very much.

|||

hi,

it's "linked" above in the "3159" word

anyway, it's at http://support.microsoft.com/default.aspx/kb/934459/en-us

regards

|||

Andrea:

There is a later one: http://support.microsoft.com/kb/935356/en-us which is Build 3161 -- Article dated 4/19/2007.

Our company has that one downloaded so I will try it when I go "off call" next Wednesday.

Thanks for your help....I hope it will work on SQLExpress.

Lisa

|||

Andrea:

I was able to apply the hotfix that I mentioned in my post on 4/19. Sorry for the delay in replying.

Thanks for your help.

Lisa

sql

Post update for SQLServer SP2--is there one for SQLServer Express?

Regarding KB935356, is there a "post" service pack 2 update for SQLServer Express?

Thanks.

hi,

LizWard wrote:

Regarding KB935356, is there a "post" service pack 2 update for SQLServer Express?

Thanks.

I'm currently at 3159 build (both on SQL Server 2005 Dev editions and SQLEpxress), so I did not install 3161, but the "Applies to" section reports SQLExpress and SQLExpress With Advanced Services as well, so you should be able to install it on them, as long as you really need them and contact Microsoft for it..

regards

|||For SQLExpress, you stated that you are currently on build 3159. Where did you get that build from? I'm currently on this version:

9.00.3042.00.

I downloaded what seemed to be the latest SQLExpress...please send the URL that you used.

Thanks very much.

|||

hi,

it's "linked" above in the "3159" word

anyway, it's at http://support.microsoft.com/default.aspx/kb/934459/en-us

regards

|||

Andrea:

There is a later one: http://support.microsoft.com/kb/935356/en-us which is Build 3161 -- Article dated 4/19/2007.

Our company has that one downloaded so I will try it when I go "off call" next Wednesday.

Thanks for your help....I hope it will work on SQLExpress.

Lisa

|||

Andrea:

I was able to apply the hotfix that I mentioned in my post on 4/19. Sorry for the delay in replying.

Thanks for your help.

Lisa

Tuesday, March 20, 2012

Post processing data flow destinations

What I am trying to do is move data from a staging table into a live environment and then update the staging table AFTER the row has move (and not errored). There does not seem to be a reliable method for doing this.

Any assistance would be appreciated.

Brett Robson wrote:

What I am trying to do is move data from a staging table into a live environment and then update the staging table AFTER the row has move (and not errored). There does not seem to be a reliable method for doing this.

Any assistance would be appreciated.

What specifically isn't reliable? It sounds to me like you need a data-flow to move the data and an Execute SQL Task to issue the UPDATE. That should work OK.

-Jamie

|||

Jamie,

I don't think your quite following what I am trying to do. I want to update the SOURCE table after the rows have moved. I don't want to update the ones which error. How does the Execute SQL Task get the appropriate row ids? They certainly won't be passed from the data-flow.

Regards,

BRETT ROBSON

|||

Brett Robson wrote:

Jamie,

I don't think your quite following what I am trying to do. I want to update the SOURCE table after the rows have moved. I don't want to update the ones which error. How does the Execute SQL Task get the appropriate row ids? They certainly won't be passed from the data-flow.

Regards,

BRETT ROBSON

Oh OK. I gotcha.

You're right, Execute SQL Task is not an option. You can execute your UPDATE from the data-flow though using an OLE DB Command component.

This will work fine - the only problem with it is that it issues an UPDATE for every row - and ths isn't very performant. Another option is to push all the successful rows into another table and update the source table from this new table. This update can be issued from the Execute SQL Task and will be much more performant because you're only doing it once.

-Jamie

|||

Thanks Jamie - either of those two should work.

post from text box to SQL insert

Hello,

I'm trying to update a single field of a record and i want to do it using a standard multi line text box but I'm not sure how to write the c# command to process the sql update. I would also like the entry to be added into the database with line breaks.

Thanks for your help

There is nothing to ask..... you can do it using the same way u r updating the others.... you do not need any c# command.... its the query on which all this depends...

you can use query... : update <table name> set <feild name>= textbox1.text where <condition>....

and about multi lines.... you do not need to worry about line breaks..... the data would be stored in the database just as the way it is in the multiline textbox.... and would be fetched in the same manner...

and do tell me if its any worthy 4 u or not.

|||

Ok - In theroy I get what your saying but then I have VisStudio post out the code I need to make the text box and the supporting data source and I get all of this:

----------------

<asp:TextBox ID="txtNotes" runat="server"></asp:TextBox>
<asp:SqlDataSource ID="sqlUpdateNotes" runat="server" ConnectionString="<%$ ConnectionStrings:dbNetOps %>" DeleteCommand="DELETE FROM [MasterServerlist] WHERE [ID] = ?" InsertCommand="INSERT INTO [MasterServerlist] ([ID], [Notes]) VALUES (?, ?)" ProviderName="<%$ ConnectionStrings:dbNetOps.ProviderName %>" SelectCommand="SELECT [ID], [Notes] FROM [MasterServerlist] WHERE ([ID] = ?)" UpdateCommand="UPDATE [MasterServerlist] SET [Notes] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Notes" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="gvServers" Name="ID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Notes" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
------------------

What I'm trying to do is :

1: display the contents of the notes field in the text box where the record matches the record selected in a gridview element

2: have the onchange event of the notes field then post back an update to the database and redisplay the new notes in the text field

I'm very new to ASP and appriciate your help.

Thank you

|||

I cannot find anything wrong in your code... could you please describe your problem in details...... or what kind of errors you are receiving(if any).....

And also you wanted to store all the data in the textbox to the database with the line breaks.... you should set the textmode attribute of textbox to multiline...

Monday, March 12, 2012

Possible to Update a table based on Excel?

Hi all
I was wondering if it was possible to update a table based off of information from Excel. here is what I though would have worked.

update MyTest Set acctNumber='111' FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\MyFile.xls;HDR=YES', 'SELECT * FROM [Sheet1$]') where [ProductGroup]='Hal Butts'

with 'Update MyTest' being the table name. It does have the same name as the excel file. Just to rule that out.

It gives me this error

Ambiguous column name 'ProductGroup'.

If it is possible what is the correct syntax??

tiborupdate MyTest Set acctNumber='111'
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0'
, 'Excel 8.0;Database=C:\MyFile.xls;HDR=YES'
, 'SELECT * FROM [Sheet1$]') WHERE [ProductGroup]='Hal Butts'Isn't complete. Your problem may be in the code that is missing from your post.

-PatP|||Well that is all the code I have.|||update mt
set mt.acctNumber = '111'
from MyTest mt
inner join OPENROWSET('Microsoft.Jet.OLEDB.4.0'
, 'Excel 8.0;Database=C:\MyFile.xls;HDR=YES'
, 'SELECT * FROM [Sheet1$]') ors ON mt.joincolumn = ors.joincolumn
WHERE mt.[ProductGroup]='Hal Butts'

The above isn't going to work, because I have no idea how you are trying to find the right columns to update based on the OPENROWSET. You need to figure it out though. You have to do something like what I have shown in the example, so you have an executable piece of code that makes sense.

Since ProductGroup is in both the MyTest table AND the spreadsheet, the UPDATE statement can't figure out which column you are referring to when you reference it.|||great thanks. its seems to be a bit long but works nicely. thank you so much.

tibor|||However....you would be better served by loading the excel file into a staging table and the perform your dml operations...excel is very unpredictable and is open to be modified by end users that could break you process...

If you do the load, only the load may fail, or if it does load, may fail a data audit the you would write...

I've come to hate excel|||Well i am still quite newbish to sql. how exactly would i load it to a staging table?|||Use defalt DTS import facility to transfer rows from excel to the table (create this table after assessing the columns on the excel sheet). Then use SELECT INTO to get the required data from staging to main table.