sql

Incremental SQL dump of mysql

Hi All, I am using MySql as a development database as well as on the server where my website is hosted. Now everday I punch new data into the database and save it as SQL dump using SQLyog. But when it comes to updating the data for that day on the server Mysql database I have to truncate the tables and then insert the new data. Wh...

Inserting numerous incremental values in a column

Got a table with 1200 rows. Added a new column which will contain incremental values - Candidate1 Candidate2 Candidate3 . . . Candidate1200 What is the best way to insert these values , non manual way. I am using SQL Server 2008 ...

Stop (long) running SQL query in PostgreSQL when session or requests no longer exist?

Hi, I'm not sure where to start on addressing this issue but if I have a AJAX web application that sends requests to the server and runs long queries on the database (postgresql in my case), is there a way to stop or kill the queries if while still running, the user refreshes the page or closes the session...etc? ...

Issue with huge table archive

I am assigned to move data from huge tables (around 20 hundred thousand record each) to identical history table. But there were when my query is running log file is over grow and mess-up everything. I tried following: For each table been archive, is handled as separate transaction Any way for history table I didn’t specify the prima...

Passing XML to Procedures

I just switched groups and what they currently do is have their middle tier pass XML to the procedures and then use xquery/xpath to parse the xml and use it to get information and return it back to the app (RETURN XML). I was just curious if others use a similar process or if they just pass the data directly into the procedures. I reall...

Is this possible in SQL?

Let's say I have a table called 'species' with 3 columns: 'Id', 'ancestorId' and 'name'. The 'ancestorId' is the 'Id' of the ancestor specie, so for example if the ancestor of the homo sapiens is the australopithecus, and australopithecus's 'Id' is 5, then homo sapiens's 'ancestorId' is 5. Let's say, also, that there is a specie called '...

Updating parent property values in SQL

Hello, I have a SQL Server 2008 database with 2 tables. These tables are defined like this: Device ------ ID Name Description TotalApplications Application ----------- ID Name DeviceID I recently added the "TotalApplications" column in an effort to speed up a query that is taking WAY too long. The number of applications associated w...

having trouble with getting rows back from msqli::multi_query

I've got an sql query that contains a number of statements. It: sets a user variable calls a stored procedure calls another stored procedure selects some data I know that the query is correct, because I've tested it in MySQL Workbench, under the same user. The query is this: set @current_post = 535; /* 535 for testing, this will be ...

Django: How do I explicitly make a query with a HAVING clause?

I need to execute some SQL that looks like this: select approve_firm_id,approve_dt,approve_result from main_approve group by approve_firm_id having MAX(approve_dt) and approve_result=0; it runs (mysql-5.1), but if I try in the Django model like this: Approve.objects.annotate(max_dt=Max('approve_dt')). filter(max_dt__gt=0).filte...

Why will Doctrine ORM will not create SQL query for my 1-to-many model??

I know this has to have an easy answer, but I cannot figure it out. After tears, I am hoping someone here can help. Here is my YML model: Identity: columns: id: type: integer(10) primary: true autoincrement: true username: type: string(255) Profile: columns: id: ...

Deleting every nth row SQL

Say I have a table (id int, Name varchar) of 1000 rows. Now I wish to delete every nth record (every 2nd, 3rd or 5th) . What is the most efficient way to do this ? ...

Support for dealing with data provider-specific differences in ADO.NET data provider-independent code?

I have an ADO.NET data access layer that has been written to work with multiple data providers, and am finding that I can't make some operations completely data provider independent. As part of my application's installation functionality, it tells the DAL to create a database with a table and some data. The DAL uses the Sql command CREA...

Index comparison between SQL Server

I have to write a sql script for comparing the difference's with the indexes of table of SQL Server. ...

Order of condition in WHERE statement could improve performances?

Hi, I have a question regarding performance and database. I use MS SQL 2008. I would like to know, if the order of condition in WHERE statement could increase or decrease performance for a SELECT operation. Example: WHERE cnt.IsPublished = 1 AND cnt.TypeContent = 'AR' AND cnt.ModeContent = 'AP' AND cnt.CategoryId = '7'; dfdfd WHE...

asp.net sql or collection problem

following is the code on Placementsearch.aspx.cs protected void Ok_Click(object sender, EventArgs e) { try { if (Page.IsValid) { int course_id = Convert.ToInt32(course.SelectedValue); int passoutYear = Convert.ToInt32(passout.SelectedValue); int ...

ASP.NET beginner ques: How to implement a simple search mechanism on my webpage?

I want to display records based on the Prod ID entered by the user in the text box..I have been looking for a tutorial to do that for over an hour now..can't find a simple one..I am a completely new to .NET..hardly know anything about grid view,sql connection and stuff.. I need a step by step tutorial that explains how to do it..I want ...

Understanding situation with multiple overlapping indexes in oracle

Given the following indexes for an Oracle database: CREATE INDEX subject_x1 ON subject (code); CREATE INDEX subject_x2 ON subject (code, status); Is it true that the first index is redundant, and can be removed. We need to get this right as this is a relatively large sized table that is going to be constantly hammered. Any oracle doc...

Codeigniter Activerecord update method refuses to insert NULL value

I'm using Codeigniters Active record library to carry out an update on a column on my DB. Here's the SQL for the table CREATE TABLE `schedules` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `reservation_id` INT(11) NULL DEFAULT NULL, `title` VARCHAR(255) NOT NULL, `description` VARCHAR(512) NULL DEFAULT NULL, `start_date` DATE NOT NULL, `st...

Adding an INNER JOIN to a query should not increase the number of rows returned right?

Hi, I have a query like the following that returns the correct number of rows that I would expect. (It has to match a similar query that returns the same data sets but with different associated info from other related tables. SELECT * FROM LK INNER JOIN STC ON LK.V = STC.VI LEFT OUTER JOIN BC ON LK.BC = BC.ID LEFT OUTER JOIN K AS LT ON ...

Which tool to use to export SQL schema from ODBC database?

I have a database in a format which can be accessed via ODBC. I'm looking for a command-line tool to generate SQL file with DROP/CREATE statements from it, preferably with all the information including table/field comments and table relations. (Possibly for a tool to parse the file and import the schema too, but I guess this would be rel...