sql

mysql_num_rows(): supplied argument is not a valid MySQL result resource

if(mysql_num_rows($result)) { echo "no match found!"; } it is throwing an error- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\Hosting\6448289\html\includes\getQuestion.php on line 72 ...

Handling change in a database schema

I am in the fairly initial stages of building an app which will hopefully be sold in the 1000's - more likely it'll be hundreds, but either way more than enough to cause a good sized headache for database schema changes. I'm rather restricted to a windows / .net / sql server environment as a number of our customers will be self hosting ...

Error when COUNT after MAX ?

Hi, I have a table Act in a medical database : IDAct Historic IDPatient 1 2001-01-01 1 1 2001-01-02 1 2 2001-01-01 2 3 2001-01-03 1 I would like to compute the column IDActPerPatient: IDAct Historic IDPatient IDActPerPatient 1 2001-01-02 1 1 2 2001-01-01 2 ...

Eliminating Duplicate Records in a DB2 Table

How do delete duplicate records in a DB2 table? I want to be left with a single record for each group of dupes. ...

Check for a field value being updated/changed SQL (Access)

Hi there, This is certainly a long shot, and is by no means vital to my development requirements, so if there's not a readily available solution the please note; I won't be too upset ;) I was wondering if there was a way to see if a field value had been changed or updated within a date range in Access. For example, I have a status fi...

Difference between in and any operators in sql.

What is the difference between in and any operators in sql ? ...

SQL Stored Procedure - Count Specific Not Null Columns in a Row

Hey hey! I have a table with multiple columns and rows - from which I need to select the count of two specific columns which are not null. In other words: LoadID,StudyID,Data,Structure,Status,Progress,Error,FileType Select the count of not null data and structure where LoadID= a number I know I could do nested IFs, but I wonder if t...

How to query several database fields based on a a single case structure

In my Oracle database, I have a table called Customers. There are fields for name, zip, city etc., but there are also fields for invoicename, invoicezip and invoicecity. For some records the invoicespecific fields are not set, and in that case the invoice method should use the information from name, zip and city. I use the following que...

Indexing in SQL

Supposing my table has 10 columns .... which columns i have to choose to create an index ? Are there any guide rules to do that ? What are the disadvantages of indexes ? If i update column which is part of INDEX then what will happen ? Does it lowers the performance of INDEXES ? ...

JPA or Hibernates With Oracle Table Partitions?

Hi, I need to use an Entity framework with my application, and I have used table - partitions in Oracle database. With simple JDBC, I am able to select data from a specific partition. But I don't know whether I can do the same with hibernate or Eclipse link (JPA). If someone knows how to do that, please do let me know. usually the sel...

sql connection string problem

I have Database (compact sql server) in a *.sdf file. I converted a compact framework project to a regular pc project and for some reason, with the same code, and the same *.sdf file the following exception was thrown: "the file name is not valid. check the file name for the database" the weird thing is that on my Pc - the substring "fi...

How do I run several .sql scripts from one query?

In SQL Server Management Studio, I want to execute a number of SQL scripts (saved queries) one after the other. This is simply to make it easier to run each. I could take each script and combine them all into one massive script and simply execute the lot, however I want it to all be separate so I can easily and simply run each bit by bit...

sql query (potentially solvable with pivot / unpivot?)

Hi, I'm not sure how best to approach this - I think a pivot / unpivot should be used, but not sure how to make it work (as pivoting column is a non-numeric) I have the following table (based on a query I can't modify): CREATE TABLE #data (donor_id NVARCHAR(50) ,last_gift DATETIME ,[2005] NVARCHAR(50) ,numgifts05 INT ,value_05 MONEY ,...

Write an efficient query

Working on an in-house ticketing system in php/mysql. This short term ticketing system has been in place for a year or so now. We are reaching 10,000 tickets and I would like to make the queries more efficient, since 9,500 or so of the tickets do not need to be looked at each day. Right now the queries are getting rows by tech id, the...

DEFINE_EDITOR=vi in sql*plus

After doing DEFINE_EDITOR=vi . I wrote SQL > edit sample.sql This is being stored in Jagan/Documents by default. But i want this to be stored in Jagan/Documents/plsql. Can anybody tell how to do this.. ...

Parse XML To build Dynamic Query

Hi All, I am trying to figure out the best way to handle a scenario where I will be passed XML that will contain criteria for a search. If the user has selected specific filters then those will be sent in the XML and if there is a section that they left unfiltered then it will not be present in the XML (Which would mean everything for ...

In Sql server, when should you use GO and when should you use semi-colon ; ?

I've always been confused with when I should use the GO keyword after commands and whether a semi-colon is required at the end of commands. When I run the Generate-script in sql server management studio, it seems to use GO all over the place, but not the semi-colon. Please can someone explain to me the differences and why/when i should...

Oracle - drop table constraints without dropping tables.

I'm doing some bulk migration of a large Oracle database. The first step of this involves renaming a whole load of tables as a preparation for dropping them later (but I need to keep the data in them around for now). Any foreign key constraints on them need to be dropped - they shouldn't be connected to the rest of the database at all. I...

ConstraintException when filling a DataGridView from a SQL Server view

Hi all, I have a SQL Server view which does a simple join of two tables and returns some of the columns. Running this view in Management Studio does not cause any problems, the expected data (two rows) is returned. When I use this view as data source for my TableAdapter in Visual Studio, I get a ConstraintException saying "Failed to en...

SqlHelper.ExecuteReader Function that executes a stored procedure

Hello, I am messing up somewhere when writing a function to execute stored procedure. I think i don't have an idea how to execute SqlHelper.ExecuteReader. in SQL server 2005 This should return the state name. But i get it empty. Any idea, why?? Thanks in advance :) reader = SqlHelper.ExecuteReader(DbConnString, System.Data.CommandTyp...