sql

finding most common value across multiple tables

Hello, given the following tables, how would I go about finding the most common ip address across all tables, and ideally, the number of times that ip occurs across all tables. bad_guys_1 bad_guys_2 | id | ip | | id | ip | +----+---------+ +----+---------+ | 1 | 1.2.3.4 | | 1 | 1.2.3.4 | | 2 | 2.3.4.5 | | 2...

SqlDataReader problem in C#, SQL Server 2005, VS 2008

I am trying to select "food_ItemName" and "food_UnitPrice" from "t_Food" table in SQL Server 2005 using C# and VS 2008. I have the following code: private SqlConnection connection; private void GetDatabaseConnection() { string connectionString = @"Server = RZS-F839AD139AA\SQLEXPRESS; Integrated Security = ...

What exactly does the EF wizard update when doing "Update model from database" in VS 2010?

Using VS2010 and .NET 4 what exactly does the ADO.NET EF wizard update when you right click in the EF model and select Update from database because I have a feeling that very little. For instance, making a column optional (null values allowed) in SQL Server Management (a value that was previously not nullable) and updating the model in...

SQL "With As" Alternative Way

In a previous question, you guys helped me grab data from a different row. The statement I am using works perfectly on the MS SQL Server Managment Studio. I can run the statement without any errors and I return the data I need. However, I need to run this data on our frontend program. When I try to run my statement on this program, it ju...

datetime issue with 01/01/1900

i have a datetime column in sql server and its optional field and if the user decided not to enter then i want to insert the value as NULL in the table and i define something like this: @deadlineDate datetime = null when i am inserting into sql server i have this code in asp.net private DateTime? GetDeadlineDate() { DateTime? get...

Want to use Excel2010 cell column as driver for SQL Server 2008 query

Tough to believe I'm the only one but..I want to use the Connection functionality in Excel to connect to a SQL Server database and populate column X based upon using a value in Excel column A as the primary key, but unable to find out how. I have tried (typing in the command text window) select name from pbaTable where pbaid = (and ...

Cannot instantiate a Zend_Table in Zend Framework

Hello, I'm using Zend Framework version 1.7.8. I am trying to create a class that extends from Zend_Db_Table_Abstract: class My_Model_Table extends Zend_Db_Table_Abstract { public function __construct($tableName) { parent::__construct(array('name' => $tableName, 'primary' => 'dummy', 'db' => Zend_Registry::get('dbAdapt...

How do I combine 40000 update queries into one?

I need to create a new column of data, assigning every 15 minutes in my data a new number. There are about 40,000 15-minute time bins to be assigned... Here is what I have so far. UPDATE [Groupers final no summer] SET [Groupers final no summer].[Fifteen min time bin daily] ='1', WHEN [Groupers final no summer].[DateTimeEDT]=Between #11...

What database engine should I use from C# that would support SQL query progress reporting?

What database engine should I use from C# that would support SQL query progress reporting? Right now I'm using Firebird, so I'd be interested in ways of implementing it mainly for it, but if it isn't possible, I'd like to know about alternatives. Speaking of alternatives, if you propose some, offer a compelling argument in the form of a ...

Execute SQL Server scripts

How can I automate process of running all SQL scripts from given folder ? ...

SQL conditionally return history.

I have a table that has notes in it. It has a bunch of notes that automatically do different thing according to what someone does in the system. When an order is assined it makes a note that says "Order was assigned to 'name'" When an order is re-assigned it makes a note that says "Order was re-assigned to 'name'" When an order is ass...

How can I find all results with a null foreign key in MySQL?

I have 2 tables... meat and potatoes in MySQL. meat_id is the primary key for the meat table and there is a meat_id in the potatoes table that links the 2 tables. I want to find all rows in the potatoes table that don't have a valid meat_id. Any ideas? ...

mysql - orderby and left outer join issue

When I use left outer join with order by in the below query the query executes infinitely without giving a resultset. However - individually they work fine that is if I change it from left outer join to inner join. But I need all the values from interregen table below. Not understanding what could possibly be the error :( My mysql qu...

Update statement running for too long or not

I'm new to working with this much data (20 million rows) and I don't know what I should expect as far as query duration: update table set field = '1234' No index on field. This statement took 25 minutes. The database is set to Simple Recovery. Does 25 minutes seem too long? Table has 9 columns with small data types <50 varchar. ...

Building an incremental query using SQL Server and .NET

I am working on an ASP.NET MVC project which allows users to construct arbitrarily complex queries by adding items clause at a time. The application then generates appropriate SQL, runs it (currently using SQL Server 2008) and displays the results, with a breakdown which includes the number of matching records for each added item. e.g....

Stack Smashing problem in real time data writing to database

Have a program that receives burst traffic .Adds to linked list and then processes to writing to database.Seen stack smashing.Then no response of asynchronous message...... ...

Between Date Literals

How do I make this work in SQL Server (2005)? The error message is 'Invalid column name' on the literals. SELECT tstamp, GVEA_Load_Net_MWH FROM DA.dbo.Oplog WHERE CAST(LEFT(tstamp,18) AS datetime) BETWEEN "01/01/2009 00:00:00" AND "01/01/2010 00:00:00" ...

Finding the actual Job number for a particular JDBC SQL connection to iSeries?

I am using the JTOpen JDBC driver to connect to the iSeries (aka AS/400, IBM System-i, IBMi, WTH?!...). I am having problems with a particular statement and it appears I need to go back to the actual SQL job QSQSRVR (or QZDASOINIT?) to find more details. Only problem is that there are hundreds of these on the system. Is there an easy w...

What are the common issues surrounding storage of XML data in a relational databases?

In relation to a discussion started at this question, I've decided to put this up as a community wiki question. The root of the question is, therefore, is it appropriate to store XML data in a relational database? Are there generally better ways to implement the same goal? What database engines provide good support for XML data types (s...

Postgres: How to fire multiple queries in same time?

I have one procedure which updates record values, and i want to fire it up against all records in table (over 30k records), procedure execution time is from 2 up to 10 seconds, because it depends on network load. Now i'm doing UPDATE table SET field = procedure_name(paramns); but with that amount of records it takes up to 40 min to proc...