sql

How to recover Accidently deleted records

Dear Friends, How to recover Accidently deleted records from SQL Server 2005? Please Friends help me Thanx in advance ...

Stored Procedure - Standards and Best practices checking

Hi All, I am Looking for an utility which can review stored procedures for Standards, best practices etc. Env is SQL Server 2005. Appreciate any help ...

trying to change data with the UPDATE function in SQL and PHP.

hey, im using PHP, and with the update-function im trying to change data in SQL. can annyone show me how that's done? thanks ...

Firebird cli import/export tool

looking for a kickass import/export cli tool for firebird db that is comparable to mysql cli tools. is fsql the best thing out there? needs to run on win,mac and linux ...

why can't I fetch sql statements in python?

I have a very large table (374870 rows) and when I run the following code timestamps just ends up being a long int with the value 374870.... I want to be able to grab all the timestamps in the table... but all I get is a long int :S import MySQLdb db = MySQLdb.connect( host = "Some Host", user = "S...

DB backend for nurse scheduling problem

I'm taking a Software Design course at Penn State and my group is tasked with solving the Nurse Scheduling Problem. I would like to have it store previous schedules as well as the current schedule in a MySQL database, but I'm not sure what the best way to do this is. For the current schedule, I was thinking of a table with the date, the...

How to Execute a SQL statement between two seperate mySQL connections?

All, is there any means by which it is possible to connect to two seperate mySQL databases and execute SQL statements to interact with both? The aim would be to query DB 1 on connection 1 and insert the results into DB 2 on connection 2. Is it possible to do this using the mySQL query browser? Many thanks, all help appreciated ...

SQL join question

I have a table table_a with a column containing data as follows: .aaa01932 .asd02343 .lkj03342 So it always starts with a period followed by 3 letters, followed by 2 number (01, 02 etc) followed by some extra numbers. I have another table table_b with data as follows: aaa01 asd02 lkj03 So it maps to the data in table_a but with th...

Partitioning the Users - multiple OpenIDs

There is database of users. Let's say that I want to support that some users can have multiple OpenID's and use them to log in and let's say that I want to partition Users in to the multiple databases. Is there some solution for this ? StackOverflow supports two OpenIDs per user, how would they do this? If the users could use only one ...

PHP and SQL Social Operations

I've got a table created using this query. CREATE TABLE `tbl_friends` ( `friend_id` int(11) NOT NULL auto_increment, `friend_status` tinyint(4) NOT NULL default '0', `friend_id1` int(11) NOT NULL default '0', `friend_id2` int(11) NOT NULL default '0', `friend_date` datetime NOT NULL default '0000-00-00 00:00:00', `friend_con...

Stored Procedure to query value of one column in First Table to Match any value in Second Table?

I wrote this but it only returns exact matchs such as 'Carburetor' not 'Brand X Carburetor' Any help would be greatly appreciated! SELECT [Col] FROM a WHERE ([Col]) IN ( SELECT [col] FROM B ) UNION ALL SELECT Distinct [col] FROM B WHERE ([col]) IN ( Select [col] FROM A ) ...

Run a single Maven plugin execution?

I thought I was an experienced Maven user, but I am having a mental block on how to do this! I've been able to use the Maven sql plugin to drop, create, and install a schema in a database via plugin executions I've defined and bound to the pre-integration-test phase. However, now I'd like to use that same sql plugin to insert some samp...

How to parse a string into a java.sql.date

Hi i am trying to parse a string into a java.sql.date Here is what i am doing private static SimpleDateFormat sdfout = new SimpleDateFormat("yyyy.MM.dd.HH.mm"); try{ String date = "2010.09.30.13.18"; task.setDueDate(new java.sql.Date(sdfout.parse(date).getTime())); } The problem is that i only get th...

Moving cursor position to a certain ID

My user can flick through a set of records. I save the last seen record _ID in Preferences, so that they can start off from where they left when they access the application next time. The cursor that I have extracts _ID field too. However, I don't know how to move cursor to that particular row. The following functions of the cursor need...

SQL Cross Apply Count

Hi, I'm trying to use CROSS APPLY in SQL, but only want to use the results of the call if the returned row count is greater than 1. I have the following SQL: INSERT INTO @dest (val1, val2, val3) SELECT t2.crossVal, t2.crossVal2, t1.tempVal FROM @tempTable t1 CROSS APPLY dbo.TableValuedFunction(t1.IDColumn) t2 Th...

Update Table with a "Select query" with a where clause

I want to Achieve the following: Current State of table (my_table) id totalX totalY totalZ --------- -------------- -------------- -------------- 9 34 334 0 10 6 56 ...

Combine SQL with PHP

$months = array('January', ... , 'December'); $sql=' SELECT * FROM `residencies` WHERE `Year` = 2010 ORDER BY array_search($months,`MonthFrom`) `DayFrom`'; Doesn't work (i already feared that), it's supposed that the elements are sorted by first the position of MonthFrom in the array $months, and those who have the same position should...

SQLite - current_timestamp doesn't return the right hour?

In the SQLite IDE SQL window, I've written the instruction to return the the equivalence of .NET DateTime.Now, which is CURRENT_TIMESTAMP. Let's say it is 10:47:00 in local time, that is, GMT -4:00 (on summertime), otherwise it is GMT -5:00. The result of my query: select current_timestamp returns 2010-09-23 14:47:00, regardless of ...

SQL joining three tables, join precedence

I have three tables: R, S and P. Table R Joins with S through a foreign key; there should be at least one record in S, so I can JOIN: SELECT * FROM R JOIN S ON (S.id = R.fks) If there's no record in S then I get no rows, that's fine. Then table S joins with P, where records is P may or may not be present ...

(SQL Server 2005) Good way to manage a large number of insert statements?

I have a stored procedure that takes a table name and writes out a series of INSERT statements, one for each row in the table. It's being used to provide sample, "real world" data for our test environment. It works well but some of these sample rowsets are 10, 20k records. The stored proc writes them out using the PRINT statement and ...