sql

Setting the 'Order By' Clause from plsql procedure parameters.

What is the best way to dynamically set the 'order by' column name and direction from parameters passed in to a plsql procedure? ...

Insert BLOB into MS SQL DB using Perl script

Hi all, Please excuse my ignorance of Perl, as I'm a .NET developer (I can hear you all spitting and cursing already ;¬) ) We have a requirment to insert a BLOB (+ some other data) to an MS-SQL DB using a Perl script (our backend systems run on AIX using Perl scripts to go about thier daily business). Our Perl guy, seemingly, ran int...

Partial SQL insert in haskelldb

I just started a new project and wanted to use HaskellDB in the beginning. I created a database with 2 columns: create table sensor ( service text, name text ); ..found out how to do the basic HaskellDB machinery (ohhh..the documentation) and wanted to do an insert. However, I wanted to do a partial insert (there are supposed ...

How can I export data from SimpleDB to Excel or TextPad?

Hi, I want to export data from SimpleDB to Excel or TextPad. How can I write a query for exporting data? Thanks, Senthil ...

Not Equal to query for SQL server

Hello, I was trying to execute a query which gets me all the info from Merchant table where PackageID is not equal to 21 or 22 or 23.. Select * from Merchant where PackageID NOT '22' Union Select * from Merchant where PackageID Not '21' Thanks!! ...

Float type in MySQL

I have a MySQL table with column of type float(10, 6). If I insert 30.064742 into the column the value stored in the database is 30.064741. Why? ...

Are database deadlocks a fact of life?

We all know about techniques to prevent db deadlocks - acquire locks in the same order, etc. But at some point, systems under pressure may simply suffer from deadlocks here and there. Should we simply accept that and always be prepared to retry when a deadlock occurs or should deadlocks be considered absolutely verboten and should we do ...

How to use ODBC to connect to SQL Server 2008 in a program written using MFC in Visual Studio 2008?

I Googled this a bit and found out that ODBC is pretty old, but I was wondering how to do this using just MFC. If I got it correctly, I have to use CDatabase, but I'm not sure how to continue. I've found out how to use a Access database (.mdb), but I have no idea about how to do it when it comes to SQL Server 2008. Thanks for your help! ...

SQL 1st of the month to the end of the month.

I have an @StartDate and @EndDate. I need the @StartDate to be the day the query is ran(which will always be the first of the month) and the @EndDate to be exaclty at the end of the month no matter if the month is 30 or 31 days, etc. ...

[SQL] Why can't I get the @@rowcount value?

Below is a simplified version of SQL script I have. print @RowNum always shows 0, rather than the real record number of the first result set. What's wrong? Thank you. declare @i int, @RowNum int set @i=0 while @i<2 begin execute StoredProcedure @i --containing a big select if @i=0 set @RowNum=@@rowcount set @i=@i+1 end print...

How does Informix deal with temporary tables when an iSQL session is dropped?

I'm curious as to how Informix (7.3) deals with temporary tables created with no log when a session is terminated without dropping those tables. I connect using iSQL: cat |isql db Then, for example, I create one or more temporary tables with no log: select first 10 * from table into temp t0 with no log; If I don't drop this table wi...

MySQL: Split column into two...

I have a table with rows like this: | Country.Number | Country | | US.01 | USA | | US.02 | USA | I'd like to modify this to: | Country | Number | Country | | US | 01 | USA | | US | 02 | USA | Is there an easy way to do this? ...

Difference between Delete and Truncate in sql server. Was I wrong... ?

Hi In a recent interview I was asked the difference between the two. I replied the general answere that all we know... The interviewer then asked if truncate can be rollbacked ? I replied no... The interviewer said that it can be rollbacked and asked me to go through the details of the behind the scene operation of both delete and t...

SQL 2008 enterprise edition install problem

I am trying to install SQL 2008 enterprise edition on window 7 machine and it fails. The error is that since visual studio has been already installed Visual studio sp1 needs to be installed. I downloaded and tried to install it and keeps on failing. Please suggest me. I would really appreciate it. ...

Problem combining multiple SQL JOINs

ALTER PROCEDURE [dbo].[GetValues] @FieldName NVARCHAR(50), @FormName NVARCHAR(50), @PoolName NVARCHAR(50) AS SELECT FieldValue FROM [dbo].[Values] INNER JOIN [dbo].[Fields] ON [dbo].[Fields].FieldID = [dbo].[Values].FieldID INNER JOIN [dbo].[FormFields] ON [dbo].[FormFields].FieldID = [dbo].[Fields].FieldID INNER JOIN...

changing left join to basic join

Hi there, I currently have some SQL that should return 3 rows of data but returns 6 (3 rows repeated twice). I believe this is down to my syntax and want to try and build the query using basic joins, currently the SQL looks like this, `function getMultiContentById($id) { $query = "SELECT FROM `mailers` LEFT JOIN `mailer_co...

How do I write this database comparison in Oracle PL/SQL?

Given databases x, y with matching schemas: //for all entries in x.MY_TABLE // if PRIMARY_KEY of entry exists in y.MY_TABLE // if {data of entry in x} doesn't match {data of matching entry in y} // print PRIMARY_KEY // else // print PRIMARY_KEY Assume that the table is a simple system...

Sql select query help

Hi all, I have a database table with data as shown below: Primary key | Column1 | Column2 | col3 | col4 |col5 --------------------------------------------------------------------- 1 | Chicago Bulls | Michael Jordan | 6'6 | aaaa | cccc 2 | Chicago Bulls | Scottie Pippen | 6'8 | zzzz | ...

SQL to handle table updates in a "dynamically typed" fashion

I'm playing around with Python 3's sqlite3 module, and acquainting myself with SQL in the process. I've written a toy program to hash a salted password and store it, the associated username, and the salt into a database. I thought it would be intuitive to create a function of the signature: def store(table, data, database=':memory:') ...

Execute sql script and not wait for completion

I have a sql stored procedure that runs for about 3 minutes, I am looking to execute this stored procedure from asp.net, but I know that if I do, that asp.net will most likely time out. I'm thinking of just creating a job within sql to have it execute that stored procedure, and have asp.net call a stored procedure to call that job. I ha...