sql

Using JButtons to execute SQL queries with JDBC

I'm writing a simple JAVA GUI to read an SQL query from a JTextFrame and execute it. The connect and execute buttons are both JButtons, but the compiler won't compile my code because I can't append a "throws SQLException" to actionPerformed in my Listener private classes. I tried writing separate methods, but the same problem still per...

orderby in sql query

Hello, I need to order sql query by a column (the three different values in this column are C,E,T). I want the results in order of E,C,T. So, of course I can't use ascending or descending orderby on this column. Any suggestions how can I do this? I don't know if that matters or not but I am using sybase data server on tomcat. ...

How can I export data from SQL Server?

I need to export database from SQL Server 2005 to SQL scripts (like we can easily do in MySQL). So I want to get generated file with scripts like this INSERT INTO ... [row 1] INSERT INTO ... [row 2] INSERT INTO ... [row 3] ... Can anybody explain how can I do this step-by-step? ...

How do I know it's time to start using SQL Caching on my website?

I'm running a fairly new website that heavily consists user generated content. I have read about SQL caching and I'm just wondering when you know it's time to switch over to SQL caching. The site doesn't appear to be slow or anything but It would be great to hear what sorts of signs start appearing to warn me when I should start lookin...

Automatically match columns in INSERT INTO ... SELECT ... FROM ...

Hi! SQL Server question. When doing INSERT INTO T1 SELECT (C1, C2) FROM T2 I don't want to specify column names of T1 because they are the same as in T2 Is it possible to do so? Currently I'm getting error Msg 213, Level 16, State 1, Line 1 Column name or number of supplied values does not match table definition. ...

Help on an (another) SQL query

Following my previous question. I have a table named activity with 2 columns: `when` as datetime // last time i saw a user guid as varchar // a unique identifier for each user I have a query that returns how many new users I have for a given date and timespan: SET @till_date='2009-11-01'; #for today, give CURDATE()+1 SET @duratio...

search functionality

How can i implement search functionality otherthan sqlquery,joins and conditional querys ...

Transpose select results with Oracle

Hi All, my question is, with some background: I have to generate some sql queries based on the table metadata (column format), and the result is something like: TABLENAME1|COL1 TABLENAME1|COL2 TABLENAME2|COL1 TABLENAME2|COL2 TABLENAME2|COL3 TABLENAME3|COL1 TABLENAME4|COL1 TABLENAME4|COL2 ... /*some other 1800 rows */ (Yeah, it's ord...

how to neglect this error in sql query

In my application i have got an error while running sql query from remote access ERROR:Operation must use an updateable query. please give me a solution ...

Adding a Total column to MDX

I have the following query that gives me an extract (I am putting this into a CSV from my cube). I want to show the Total of all NRx in a column as the first column NRx and the rest of the NRx columns should come up as they do now. I tried to add a SUM (Measures.NRx) to this, but it did not work How do I get a Total NRx column? SELECT...

use of in Keyword IN keyword in Query

hi. select * from resource where ResourceID= 1 and ResourceKeyword in(gallery 1,1980) I have an table called resource with columns ResourceID, ResourceKeyword ResourceKeyword can contain multiple values when ever I am using this query I get an syntax error what is syntax to solve it thank you ...

SQL-Server infinite loop

how does sql-server handle infinite loops? Does it detect it or kill the server. EG: WHILE (@number = 3) BEGIN print @number END ...

Different record count values in one query

Hi, My goal is to achieve a result set like the following CODE | TOTAL1 | TOTAL2 1 | 56 | 34 2 | 12 | 15 3 | 90 | 3 There are 2 tables e.g tableA and tableB The counts are different by tableB.type SELECT code, COUNT (*) AS total1 FROM tableA a WHERE a.ID IN (select ID from tableB where type = 'XYZ'...

SQL getting max date from two tables

Hi, I have two tables USER (one row per user) id,username,firstname,lastname,lastmodified 1,johns, John,Smith, 2009-03-01 2,andrews, Andrew,Stiller, 2009-03-03 STUDIES (multiple rows per user) id,username,lastmodified 1,johns, 2009-01-01 1,johns, 2009-02-01 1,johns, 2009-07-01 2,andrews,2009-05-05 2,andrews,2009-04-04 I want to g...

PHP/MySQL - Storing array in database

Hi, I'm working on a PHP app which requires various settings to be stored in a database. The client often asks if certain things can be added or changed/removed, which has been causing problems with the table design. Basically, I had a lot of boolean fields which simply indicated if various settings were enabled for a particular record...

How much real storage is used with a varchar(100) declaration in mysql?

If I have a table with a field which is declared as accepting varchar(100) and then I actually insert the word "hello" how much real storage will be used on the mysql server? Also will an insert of NULL result in no storage being used even though varchar(100) is declared? What ever the answer is, is it consistent accross different data...

Transact-sql insert in two tables at once?

Ok, this will sound weird, but can you do an insert in a join of two tables? I have a table A and a table B with a foreign key to A. Now I want to copy multiple records of table A in one query + a copy of the records in table B with foreign key to the records being copied in table A (but as foreign key the new identities). Hope somebod...

Stored proc running 30% slower through Java versus running directly on database

Hi All, I'm using Java 1.6, JTDS 1.2.2 (also just tried 1.2.4 to no avail) and SQL Server 2005 to create a CallableStatement to run a stored procedure (with no parameters). I am seeing the Java wrapper running the same stored procedure 30% slower than using SQL Server Management Studio. I've run the MS SQL profiler and there is little...

Java seems to be truncating long string result from MS-SQL query

So I've got a query in a JSP class that retrieves, basically, the entire contents of a table as a string using MS SQL's "FOR XML AUTO" feature. I.e., select * from userdata for xml auto. The problem is that the result is being truncated at around 2033 characters. There's no unusual character at that point or anything; the break occurs...

How to add a new row to an existing table using c# sql server

I need to write a program. A part of the program is to write to an sql database (.mdf). I had a lot of trouble trying to add a new row to my table (called: "Data"). Here is the code: ... DataSet ds = new DataSet(); System.Data.SqlClient.SqlDataAdapter da; DataRow dRow; string sql = "SELECT * From Data"; da = new System.Data.SqlClient.Sq...