I've got a column in a SQL Server table that is type XML. I want to change multiple values in the XML in a stored proc. I've already found the XML.Modify(...) command and have it working for a single value. Can I change multiple values in the XML in one update command or do I need to do it as multuple update commands?
You will need to use multiple (xmlcol).modify calls - you cannot update multiple bits at once, as far as I know.
Related
I'm having some problems with a query generated by a program I use. The program make an insert into two different databases on different servers:
INSERT INTO Sumas (codeje, codcta, codpercon, impdeb)
VALUES ('2018', '6311001', 9, -8000)
On the first server, the query works fine, but on the other server, I have a problem with a null value. The complete table:
I assume that if I don't pass the value, one server use the null and the other use blan^k. There is any configuration where I can change this?
Look at the schema for the table and examine the field for a possible default value. If you have the ability to change it, update it so that the two are the same.
I am currently working with a stored procedure that performs some background processes and then returns one of two results tables.
If it works ok I get a one column table that says success, if it doesn't then I get a four column table with various error data.
While this is fine if you just execute the code from .net, I now need to execute this from within another stored procedure. While I don't need the output, I do need the background processes to take place. I'd usually insert the output into a table, but can't in this case as the columns in the output varies dependent on the result, and as such cannot define a table that it can insert into.
Easiest answer would be to rewrite the outputs of the background SP to be consistent but this isn't an option. I've even tried wrapping this inside a UDF but the stored procedure can't be called from with a function.
Whatever solution I finally use it must work on versions from SQL Server 2008 R2 up to 2016.
Does anybody have any suggestions?
Many thanks,
Mat.
I would image you could create a SP that inserts the result of the inner SP into a temporary table using the hack below.
Insert results of a stored procedure into a temporary table
If that blocks the ouput then you can return no data.
In SSIS, I am feeding a XML file and using XSLT getting one resultant XML(with my required field) file.
Could I use the result of XML task to directly feed the SQL table.
While exploring in this regard..i got to know I can save the result of XML task to a variable and can use this variable to put the data in SQL table.
Not sure how to accomplish this or is it possible ?
If you have the resultant value contained within a varaible. Assuming it is just one value. You could use a Parameterised Execute SQL Task to accomplish this.
I'm trying insert a large xml document (about 10MB) into a Sql Server 2008 table, the XML document is built at run-time.
Is there a better way to perform this insert. I'm using a simple insert command with one parameter of type string, but it doesn't work. In the table, the field is showing a NULL value.
Is there a way to do this with a single insert?
Try to use BULK INSERT expression to increase performance.
http://msdn.microsoft.com/ru-ru/library/ms188365.aspx
I have a SQL Server 2008 database. This database has a stored procedure that will update several records. The ids of these records are stored in a parameter that is passed in via a comma-delimited string. The property values associated with each of these ids are passed in via two other comma-delimited strings. It is assumed that the length (in terms of tokens) and the orders of the values are correct. For instance, the three strings may look like this:
Param1='1,2,3,4,5'
Param2='Bill,Jill,Phil,Will,Jack'
Param3='Smith,Li,Wong,Jos,Dee'
My challenge is, I'm not sure what the best way to actually go about parsing these three CSVs and updating the corresponding records are. I have access to a procedure named ConvertCSVtoTable, which converts a CSV to a temp table of records. So Param1 would return
1
2
3
4
5
after the procedure was called. I thought about a cursor, but then it seems to get really messy.
Can someone tell me/show me, what the best way to address this problem is?
I'd give some thought to reworking the inputs to your procedure. Since you're running SQL 2008, my first choice would be to use a table-valued parameter. My second choice would be to pass the parameters as XML. Your current method, as you already know, is a real headache and is more error prone.
You can use bulk load to insert values to tmp table after that PIVOT them and insert to proper one.