sql

SQL: Using NULL values vs. default values

What are the pros and cons of using NULL values in SQL as opposed to default values? PS. Many similar questions has been asked on here but none answer my question. ...

In Excel how to create multiple rows from a single data row

Hi I have an execl datasheet with data looking like this id desc part no 1 Qty 1 part no 2 Qty 2 part no 3 Qty 3 1 PartsName 382A012-3-0 3 382A023-3 3 382A012-25 3 And need it to look like this id desc part no Qty 1 PartsName 382A012-3-0 3 1 Part...

difference between SQL and Prolog

Hi, I've started learning Prolog and wondering about theoritical difference from SQL language. For example they are both declarative paradigma languages, both support fact-driven knowledge database, both support question-styled data-retrieving, both support functional dependencies. So does anybody have an idea? Tnx in advance. ...

How to empty a SQL database?

Hello, I'm searching for a simple way to delete all data from a database and keep the structure (table, relationship, etc...). I using postgreSQL but I think, if there a command to do that, it's not specific to postgres. Thanks, Damien ...

Modifying a function used as a column default in SQL Server

Hi, We're having an issue with a poorly coded SQL function(which works fine in live, but not in our test environment). This function is used to provide a default value in many tables, trying to ALTER the function returns a "Cannot ALTER ### because it is being referenced by object" error. Is there any way round this error message? T...

SQL Associative Entity question

Hello, I have a SQL question. I'm working with the following set of tables: http://imgur.com/eg19r.png The Recipe table contains 5 recipes, Ingredient contains many ingredients (52), and IngredientList is an associative entity, an implementation of the many-to-many relationship between Recipe and Ingredient. RecipeID and IngredientI...

Correct sql/hql query (aggregate in where clause)

I want to do query as below. Query is wrong but describes my intentions. SELECT name, dateTime, data FROM Record WHERE dateTime = MAX(dateTime) Update: Ok. The query describes intentions not quite good. My bad. I want to select latest record for each person. ...

How to write efficient MySQL query to delete specific rows depending on constraints

Hello all! I got a question regarding my MySQL-database and would like to get input on what would be most efficient. My problem is as follows, I'm developing premium functionality for my board game web site. One premium functionality would be that all the games a user has played would be stored "forever" (for the user to look up after...

Java: Trouble connecting to MySQL

I'm writing a desktop java app on that I want to connect to a MySQL database on a server. Here is the code to do that: import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; private static Connection getDBConnection() throws SQLException, InstantiationException, IllegalAcces...

Why does this 'modify table' statement fail?

I'm trying to add a 'not null' constraint to a column in Oracle 9. ALTER TABLE user_roles modify group_id varchar2(36 char) set not null; However, the operation fails with an odd error: Error report: SQL Error: ORA-12987: cannot combine drop column with other operations 12987. 00000 - "cannot combine drop column with other operation...

Connection error in sql server 2005

hello ! I have a problem,I run application C# and I get a error "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (p...

How to determine field-type for SOLR indexing?

I have two table fields in a MySQL table. One is VARCHAR and is a "headline" for a classified (classifieds website). The other is TEXT field which contains the "text" for the classified. Two Questions: How should I determine how to index these two fields? (what field-type, what classes to use etc) Currently I have an "ad_id" as a uniq...

Access SQL Server 2008 Change Tracking Info via Entity Framework

Based on this link it looks like I can get date inserted / date modified information "for free" (without the need for triggers etc.) using Sql Server 2008 by simply enabling Change Tracking. I am using Entity Framework to access the data. My question is, how do I access date modified / date inserted information for the database records...

Output two columns for 1 field for different date ranges?

Hi, I have a SQL table "ITM_SLS" with the following fields: ITEM DESCRIPTION TRANSACTION # DATE QTY SOLD I want to be able to output QTY SOLD for a one month value and a year to date value so that the output would look like this: ITEM, DESCRIPTION, QTY SOLD MONTH, QTY SOLD YEAR TO DATE Is this possible? ...

SQL - how to delete from one table while refering fom other table?

how can i delete from table A while comparing two fields A.P and A.C to table B's B.P and B.C while looking for all matches of B.R = 1 ? actually neither of the following work but it should go into the direction, unfortunately i can't figure out how... DELETE FROM A WHERE (A.P = B.P AND A.C = B.C where B.C = 1) DELETE FROM A WHERE (SE...

Is it possible to save and reuse a set of Parameters as a code block in SQL Server Express 2005?

I have several stored procedures that all use the same set of parameters. Is there a way to define and save the parameter list as a reusable block of code? Something like this: CREATE PROCEDURE test Using StoredParameterList AS BEGIN SQL Statement END Is this possible? It would make code maintenance easier if a parameter n...

how to manage sql server 2008 that came with Visual studio 2008 ?

hi i install visual-studio 2008, part ot the installation is the sql server 2005 express. how i can manage this sql server ? is there any visual tool for making tables ? run queries ? thank's in advance ...

Selecting data from two mysql tables in one query

Hi everyone, I have two tables, landlords and properties. My properties table has; ID, Address, Postcode, lease and landlordID in it. The problem I face is: If I want to search for all the properties that have Mr.Spina as their landlord I need search the landlords database with the name "spina" to get his ID which is saved in the prope...

insert a value calculated from another table

Hi All I would like to do a query for inserting a value calculated starting upon another table. I don't want to use Temporary tables and I would like to do everything in one singel query. It is possible? I tried this one below but it doesn't work. Thanks AFeG INSERT INTO MyTable( `DATE`, `Name`, `Total` ) VALUES ( '2010/01/01', ...

What is better: to have many similar databases or one database with similar tables or one database with one table?

I need to work with several data samples, to say, N. The samples represent similar data but from different origins. For example, history of order in different shops. So the structure of all the samples is the same. To operate with the data I have several possibilities: Use N databases with identical schema, one for each sample Use one ...