|
Qazzy64 wrote: there is no null values allowed so it either a number or -999 if null when table is loaded.
Just curious; does that mean that you replace a null-test with a test for -999, and act according? Why was null disallowed anyway?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
When they load the table it has a number(ID) or if its null they load -999 so they know to reprocess it later on when other matching data shows up. Hope that helps.
|
|
|
|
|
The reason I asked is because it does not make any sense to me; you'd still have to deal with the same type of checks. The only difference being that the new "strategy" will be alien to new developers, and will cause weirder and harder to debug-exceptions than a null-reference would.
I might be missing some obvious advantage of the approach. So, where is it? What's the 'added value' of using a marker-value above a null-value?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I agree with you that doing anything causes more problems eventually. Myself i would not have brought the data forward until all fields are present from source file. But i do not make that choice and i got involved after project was started. This is more of a transactional system then data warehouse like they said. Hate to say it but it goes back to the way it was architected and going forward from there has been to get it to work. Very complex data modeling which i would have simplified by bringing it in and leveling data types. They chose to bring it forward anyway and then leave just before the DW level. Makes no sense but i wasnt in on those meetings. I get to deal with it and figure out if the data is accurate. Fun times.
|
|
|
|
|
Hi Mr
i have a problem in ssis when i tried to use xml file to import to any data sources
i used Multicast to test no or rows returned but no returned rows
i can't attach xml file in the message
please save as GetGroups.xml and test it and send me the result
="1.0"="utf-16"
<DataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="T">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="0" />
<xs:element name="NodeGroup" type="xs:string" minOccurs="0" />
<xs:element name="NodeCount" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet>
<T diffgr:id="T1" msdata:rowOrder="0">
<ID>648</ID>
<NodeGroup>Moustord</NodeGroup>
<NodeCount>5</NodeCount>
</T>
<T diffgr:id="T2" msdata:rowOrder="1">
<ID>646</ID>
<NodeGroup>Shell</NodeGroup>
<NodeCount>9</NodeCount>
</T>
<T diffgr:id="T3" msdata:rowOrder="2">
<ID>647</ID>
<NodeGroup>Suze</NodeGroup>
<NodeCount>4</NodeCount>
</T>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
modified 9-Oct-12 1:55am.
|
|
|
|
|
i tried to use OPENROWSET like that but it's not work can you modify it
DECLARE @xml XML
SET @xml = '<DataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="T">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" minOccurs="0" />
<xs:element name="NodeGroup" type="xs:string" minOccurs="0" />
<xs:element name="NodeCount" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet>
<T diffgr:id="T1" msdata:rowOrder="0">
<ID>648</ID>
<NodeGroup>Moustord</NodeGroup>
<NodeCount>5</NodeCount>
</T>
<T diffgr:id="T2" msdata:rowOrder="1">
<ID>646</ID>
<NodeGroup>Shell</NodeGroup>
<NodeCount>9</NodeCount>
</T>
<T diffgr:id="T3" msdata:rowOrder="2">
<ID>647</ID>
<NodeGroup>Suze</NodeGroup>
<NodeCount>4</NodeCount>
</T>
</NewDataSet>
</diffgr:diffgram>
</DataSet>'
;WITH XMLNAMESPACES(
'http://www.w3.org/2001/XMLSchema' AS ns,
'urn:schemas-microsoft-com:xml-diffgram-v1' AS diffgr )
SELECT
fd.c.value('(ID/text())[1]', 'INT') 'a',
fd.c.value('(NodeGroup/text())[1]', 'nvarchar(255)') 'b',
fd.c.value('(NodeCount/text())[1]', 'INT') 'c'
FROM @xml.nodes('ns:DataSet/diffgr:diffgram/NewDataSet/T') fd(c)
|
|
|
|
|
Hi,
What's the problem with this code?:
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_delete_channel`(IN param_channel_id int, IN param_volow_member_id int, OUT param_is_channel_created bit)
BEGIN
DELETE FROM member_posts WHERE member_channel_id = param_channel_id;
DELETE FROM member_channels WHERE member_channel_id = param_channel_id;
IF NOT EXISTS (SELECT member_channel_id FROM member_channels WHERE volow_member_id = param_volow_member_id) THEN
BEGIN
UPDATE volow_members SET is_channel_created = FALSE;
SET param_is_channel_created = FALSE;
END;
ELSE SET param_is_channel_created = TRUE;
END IF;
END
I am not getting any error on mysql neither on the .net application?!!
here is my .net code:
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_command = new MySqlCommand("sp_delete_channel", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_connection.Open();
sql_command.Parameters.AddWithValue("param_channel_id", channel_id).MySqlDbType = MySqlDbType.Int32;
sql_command.Parameters.AddWithValue("param_volow_member_id", Convert.ToInt32(Session["volow_member_id"])).MySqlDbType = MySqlDbType.Int32;
sql_command.Parameters.AddWithValue("param_is_channel_created", MySqlDbType.Bit).Direction = ParameterDirection.Output;
int result_row = sql_command.ExecuteNonQuery();
if (Convert.ToBoolean(sql_command.Parameters["param_is_channel_created"].Value) != true)
{ Session["is_channel_created"] = false; }
|
|
|
|
|
Not getting any errors could sometimes be thought of as a good thing.
What's the problem?
|
|
|
|
|
that's what's making me crazy!
no error in Mysql nor C# code
but the MySQL code is not getting invoke. DELETE is not happening!
|
|
|
|
|
..
Try 'debugging'. What does the row-count return? What happens if you put a 'SELECT 1' in there, without any parameters, does that execute?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
How do you know that the DELETE did not happen? Did you check in the database?
What do you expect to get at int result_row = sql_command.ExecuteNonQuery(); ?
|
|
|
|
|
yes i checked the database itself. records were not deleted and no error were thrown
|
|
|
|
|
This line
sql_command.Parameters.AddWithValue("param_is_channel_created", MySqlDbType.Bit).Direction = ParameterDirection.Output;
is wrong. AddWithValue expects a value as the second parameter but you are providing it a data type (did you mean to call Add method?). Anyway, you should not be providing a value to an output parameter.
I'm not sure if this is what is the cause of your problem.
|
|
|
|
|
how can i proivide an value?? it's an OUT parameter
|
|
|
|
|
I even tried this simple delete but still not working. No error and records not getting deleted!!!
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_command = new MySqlCommand("sp_delete_channel", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_connection.Open();
sql_command.Parameters.AddWithValue("param_channel_id", channel_id).MySqlDbType = MySqlDbType.Int32;
int result_row = sql_command.ExecuteNonQuery();
and SQL:
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_delete_channel`(IN param_channel_id int, IN param_volow_member_id int, OUT param_is_channel_created bit)
BEGIN
DELETE FROM member_posts WHERE member_channel_id = param_channel_id;
DELETE FROM member_channels WHERE member_channel_id = param_channel_id;
IF NOT EXISTS (SELECT member_channel_id FROM member_channels WHERE volow_member_id = param_volow_member_id) THEN
BEGIN
UPDATE volow_members SET is_channel_created = FALSE;
SET param_is_channel_created = FALSE;
END;
ELSE SET param_is_channel_created = TRUE;
END IF;
END
|
|
|
|
|
Hi everyone. I'm trying open a connection to sql server database in a background thread while showing a progress dialogbox that has a Cancel button.
I would like to know how I can terminate the connection when the Cancel button is clicked and SqlConnection.Open call is still connecting. Thanks.
|
|
|
|
|
I'm afraid you cannot do that. SqlConnection.Open is a blocking call and control will not return to the calling code until the method completes. And I'm not aware of any asynchronous way of opening a database connection.
I stand corrected. Check Eddy's answer below for an asynchronous way of doing this.
modified 4-Oct-12 15:20pm.
|
|
|
|
|
Use OpenAsync[^], or it's overload[^].
--edit
For which version of Sql Server? Take note of the "supported platforms" in the documentation.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy. The function is available only in .net framework 4.5 which I'm not using.
I tried in my own way which works fine now. My BackgroundWorker thread creates a new thread and the created thread rather calls SqlConnection.Open(). When the cancel button is clicked, the BackgroundWorker thread aborts the thread opening the connection.
It works fine although I don't know if there could be any related problems. I have run the application several times just to try that part of the code and I haven't found any problems.
|
|
|
|
|
Dan_K wrote: I tried in my own way which works fine now. My BackgroundWorker thread creates a new thread and the created thread rather calls SqlConnection.Open(). When the cancel button is clicked, the BackgroundWorker thread aborts the thread opening the connection.
That's what the OpenAsync in 4.5 will do; open the query on a backgroundthread, polling it's status.
Dan_K wrote: It works fine although I don't know if there could be any related problems.
Opening a connection can fail for multiple reasons, and exceptions aren't casted across the thread. You might want to make sure you have a good exception-handler in there; if you have the time, then it'd be mighty cool to have a "try connecting again" function - that way people won't have to relaunch the app after they found out that the database-server wasn't powered on.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
We've upgraded one of our systems to SQL 2008R2 and certain parts are running like a dog. One statement that would have taken an average of 20-40mins on the old box, took from 11:40 to 00:35. Its not every statement but odd ones.
Its a 2 cpu box, and the cpu usage sits a 50%, there's hardly any activity in activity monitor (no significant resource waits etc, no io, or requests)
Unfortunatley this didn't happen during conversion, system test or uat, so we've imp'ed, and now hitting these issues
Has anybody got some hints, places to look, good resources to read up on?
One thing we would like to work out, is it a fact, 2008 does things differently and query design, indexes etc need to be re-developed/analysed?
|
|
|
|
|
Rebuild all indexes and do update statistics and then try again.
|
|
|
|
|
Rebuilding indexes didn't seem to help.
But updating all the stats did, the sample I was looking at now processes in 6s rather than 9h.
My concern now is I have Auto Update Stats On, and Update Stats Async, and the way the system works is it that each stage wipes the working tables before processing. So the stats would be invalidated every run.
Now we obviously could go through and do manual stat updates, but should we need to? Given we didn't for 2000.
Also I think that SQL is memory starved, would this be preventing it from also auto-updating stats?
|
|
|
|
|
Since it seems that you can isolate it down to a SQL statement, then you might want to put that SQL statement in SQL Server manager and under the query menu, enable the option to "Include Actual Execution Plan". After running the statement, you should get an idea of where the problem lies.
You can also do things like including statistics.
Good luck.
|
|
|
|
|
In our couple of runs we have identified 2 separate statements, the problem is this system is wiped each run and the data then passed through changes in size, so we probably have not found them all. We've also not been down all the varying processing paths.
So I was wondering if in doing a conversion to 2k8, you will always find statements that no longer work efficiently and you just have to find them all and fix. Or if there is something we might have set wrong?
If everyone says its the former then fine, I can plan for that, just want to make sure before saying we need to make more changes.
|
|
|
|