sql

Error with varchar(max) column when using net.sourceforge.jtds.jdbc.Driver

Hi I have a MS SQL database running (MS SQL 2005) and am connecting to it via the net.sourceforge.jtds.jdbc.Driver. The query works fine for all the columns except one that is a varchar(max). Any ideas how to get around this issues? I am using the jdbc driver to run a data index into a SOLR implementation. (I do not control the dat...

dynamically create table statement in sql

how to dynamically create a table with same columns as that of previous table. in sql ...

How to combine IN operator with LIKE condition (or best way to get comparable results)

I need to select rows where a field begins with one of several different prefixes: select * from table where field like 'ab%' or field like 'cd%' or field like "ef%" or... What is the best way to do this using SQL in Oracle or SQL Server? I'm looking for something like the following statements (which are incorrect): select ...

Oracle analytic function window defined by data

I have a table which represents a line-by-line dump of the data read from a particular text file format. Each line may represent a "master" or a "detail" line, indicated via rec_type code. I'd like to write a query that gets the "master" lines alongside the associated detail lines. I've come up with something that does the job, but it se...

Django: Multiple COUNTs from two models away.

I am attempting to create a profile page that shows the amount of dwarves that are assigned to each corresponding career. I have 4 careers, 2 jobs within each of those careers and of course many dwarves that each have a single job. How can I get a count of the number of dwarves in each of those careers? My solution was to hardcore the...

How can I implement this functionality into SOLR?

I have a classifieds website, and users may for example search for cars. When searching for a car, there are a number of endings in their names as you all probably know. For example lets say Bmw 330ci (ending beeing 'ci'), but there is also Bmw 330i, or Bmw 330di etc etc. How can I make SOLR "understand" this, so if users search for 33...

SUM() Problem in Paradox Database

Hello All, I'm currently working with a paradox database that was implemented before I started working at my current job at an insurance firm. Long story short is that when I am trying to to compile a query of the debit/credit balances of all the active clients, it gives me a different balance per client if I do a query for each indivi...

SQL Compact C# .... Couple of Questions

I have a few questions regarding Compact SQL. I am using VS C# 2008 Express by the way. 1) Are there any GUI tools for creating and managing the databases? 2) Once the DB is created, and the app is released, would the app have to create the database each time the user installs it? Or can I create the database and include it with the ap...

Simple SQL Primary Key question

Hi , just a quick noob question. Why would you use a primary key in a database ? ...

Return master rows based on detail filter

Hello I have a query where I want to return Master rows based on whether the detail fulfil a certain criteria. For example, I only want to return a particular Master row if AT LEAST one of the Detail rows have SomeProperty = X. Based on the following predicate: predicate = predicate.And(p => ...

Sql commands using joins for the follwing four tables

There are four tables Employee (Employee_id,name,chief_id) Department(Department_Id,name) Emp_Dep(Employee_id,Department_Id) Emp_Sal(Employee_id,salary) Now I need to write a query which displays Employee IDs who get maximum salary in each department. ...

Partitioning Existing Tables

Hello, How do i partition existing table in SQL Server 2005/08 ? I couldn't find a better clue on it. ...

Strange Oracle date behavior

I had a strange problem in one of our production databases. Long story short, simple query: select id, trunc(stdate) from table_name where trunc(stdate) = '05-FEB-09'; returned no rows. However, select trunc(stdate) from table_name where id = sought_after_id; returned '05-FEB-09'. Only after I tried: update table_name set stdate...

Select row which has all five under it in the "tree"

Hello I have two tables. One is article and the other structure. And the articles can be viewed as a tree with childnodes and so on. Like the Windows forms control TreeView. The structure table basically looks this: article_id article_above_id Article: article_id article_number I want to select from a maximum of five article_nu...

T-SQL : How to count empty tables in database?

Hi, is any way to count tables with no rows in my database with t-sql on sql server 08? Thanks ...

How to avoid nested SQL query in this case?

I have an SQL question, related to this and this question (but different). Basically I want to know how I can avoid a nested query. Let's say I have a huge table of jobs (jobs) executed by a company in their history. These jobs are characterized by year, month, location and the code belonging to the tool used for the job. Additionally I...

Pivot table display

HI, I am having data as shown below ItemCode Attr1 Attr1 InStock ITEM-000001 43 S 1 ITEM-000001 52 L 2 ITEM-000006 42 R 1 ITEM-000006 44 R 2 ITEM-000009 56 R 1 ITEM-000011 40 R 2 And by using Pivot table (or any other technique) i want the reslut like as Output f...

What is a columnar database?

I have been working with warehousing for a while now. I am intrigued by Columnar Databases and the speed that they have to offer for data retrievals. I have multi-part question: How do Columnar Databases work? How do they differ from relational databases? Is there a trial version of a columnar database I can install to play around?...

SQL Server Database analysis using T-SQL

I have a small application which has around 38 tables in the Database (SQL Server 2000/2005). Now i would like to know how much data (in KB's/MB's not records) they are taking using T-SQL. Saying in better way i would like to do analysis of entire database. Is that possible? How ? Thanks All, ...

SQL: Get list of non-coupled items using MySQL 4

I'm not that good in SQL and I've come across a problem I don't know how to solve. I've read and re-read parts of a book about SQL (O'Reilly's Learning SQL) which I hoped would contain the information I needed but I haven't found it. My problem is the following. I'll use a simplified example to make it easier to discuss. I've got three...