sql

How to change the collation of sqlite3 database to sort case insensitively?

I have a query for sqlite3 database which provides the sorted data. The data are sorted on the basis of a column which is a varchar column "Name". Now when I do the query select * from tableNames Order by Name; It provides the data like this. Pen Stapler pencil Means it is considering the case sensitive stuff. The way...

How to "order by" a column and "Include Column Name with query"?

Hi, I am trying to run a sql query in excel and I want to : 1. order the query result by my column "Stationname" 2. include the column names with the query Right now it is returning all the columns without the column name, and the end users do not know what it is. Could someone please help? I am stuck! Below is my current code: ...

SQL Four Tables One Recordset

What am I missing? I need to return all records that match the Last_Name Query whether they do or do not have a Customer Number in the Field_Table. I am calling the Client table twice because each client Id has a parent whose contact number = 0. I need the parent record to return the city, state, zip and company name. I have tried loo...

mySQL (5.1.35): SELECT INTO not working

I'd like to test a situation, but I need to add a dummy row of data to test the hypothesis. So, according to this mySQL manual page for SELECT INTO, my query is correct: SELECT INTO courses.sections_rfip (SectionID, CourseID, SectionNumber, Term, Credits, CutOffDate, StartDate, EndDate, LastDateToWithDraw, ContinuousIntake, AcceptsRe...

Same data, two different ways to store it

Hola, The two tables below can both hold the same data - a full year, including some arbitrary info about each month table1 (one row = one month) ------ id month year info table2 (one row = one year) ------ id year jan_info feb_info mar_info apr_info may_info jun_info jul_info aug_info sep_info oct_info nov_info dec_info Table A ...

SQL 2005 Merge Replication and Transaction Logs

Hello, I have multiple databases using merge replication with , @publication_compatibility_level = N'90RTM', @replicate_ddl = 1. I have a backup job on the publisher database that does a full backup nightly. I have another job that backs up the transaction log every 3 hours and runs DBCC SHRINKFILE (N'TheDatabaseName_Log' ) on the publ...

How do I run my .sql script file through ADO.NET?

I want to run my .sql script file using my ASP.NET website through ADO.NET. How it could be it is not working? When I try 'dbScript is a string and contains contents of the .sql file' Dim cmd As New SqlCommand(dbScript, con) Try con.Open() cmd.ExecuteNonQuery() Catch ex As Exception Finally con.Close() cmd.Dispose() End...

Common programming mistakes for SQL developers to avoid?

In the spirit of javascript .net What are the common mistakes we should avoid when programming in SQL? ...

C#: How to import SQL-script into database programmatically?

Do I have to parse the SQL-script manually and execute each statement separately or are there better ways? Iam looking for a programmatically solution, I know there are tools which are already able to do this. It would be good if the solution would work for all database systems, not just sqlite. ...

MySQL Weekday/Weekend count - Part II

Hey everyone, I have posted about this before, which helped to give me the following SQL: SELECT fname, MONTH( eventDate ) , IF( WEEKDAY( eventDate ) <5, 'weekday', 'weekend' ) AS DAY , COUNT( * ) FROM eventcal AS e LEFT JOIN users AS u ON e.primary = u.username GROUP BY fname, MONTH( eventDate ) , IF( WEEKDAY( eventDate ) <5, 'we...

Local Temporary table in Oracle 10 (for the scope of Stored Procedure)

I am new to oracle. I need to process large amount of data in stored proc. I am considering using Temporary tables. I am using connection pooling and the application is multi-threaded. Is there a way to create temporary tables in a way that different table instances are created for every call to the stored procedure, so that data from ...

SQLAlchemy: Operating on results

I'm trying to do something relatively simple, spit out the column names and respective column values, and possibly filter out some columns so they aren't shown. This is what I attempted ( after the initial connection of course ): metadata = MetaData(engine) users_table = Table('fusion_users', metadata, autoload=True) s = users_table....

Update all rows of a single column

Hi, I'm dealing with two tables which have 2 columns, as listed under. Table 1: table_snapshot account_no | balance_due Table 2: table_ paid account_no | post_balance | delta_balance I added a third column to table2 with the following command: ALTER TABLE table_paid ADD delta_balance number(18); I'm trying to use the following que...

Help Needed in SQL Query

Dear Friend, Below is my SQL Query which run against 30000000 rows and its takes 6 minutes to run indexes are defiened to the all columns used in the where clause as wll as inner join Please help me SELECT auditData.id,nstmp.ProviderMaster_ID as CDRComment,Auditdata.Calltypetag from Auditdata AuditData inner join NoSeriesMaster_t...

What's wrong with this SQL statement?

SELECT * FROM Questions INNER JOIN QuestionKeyword INNER JOIN Keywords ON Questions.ID=QuestionKeyword.QuestionID AND QuestionKeyword.KeywordID=Keywords.ID WHERE Keywords.Keyword LIKE '%es%' It says: Incorrect syntax near the keyword 'WHERE'. ...

SQL Server 2005 recursive query with loops in data - is it possible?

I've got a standard boss/subordinate employee table. I need to select a boss (specified by ID) and all his subordinates (and their subrodinates, etc). Unfortunately the real world data has some loops in it (for example, both company owners have each other set as their boss). The simple recursive query with a CTE chokes on this (maximum r...

Implementing a virtual list in Java

I need to fetch many records from an RDBMS in Java (10-20k) my target system expects them to be available as Java List. So I want to implement my code as "Virtual list" where I actually only fetch the records I actually need. I expect SQL like SELECT * FROM CUSTOMER WHERE COUNTRY="Moldovia" as parameter and just return what is requeste...

hibernate sql query

hi, i have a strange problem with a hibernate sql query: The db relations are like follows: registration has one invoicerecipient registration has many attendees i have the persid of an invoicerecipient, so I should get in both following cases the associated registration, but only the second case works. Does anybody know why the firs...

How to write a SQL Loader control file to load data into multiple tables

I have a data file with 3 different sets of information like this below: @@@08016995BUILD 12/15/04POSITION "AABPX ","76826309","M","L"," 1509.4340" ----More similar Records_------------------------- @@@08016995BUILD 12/15/04SECDESC "AABPX ","mf","AMERICAN AADVANTAGE BALA","NCED PLAN AHEAD "," "...

Using temporary table in where clause

I want to delete many rows with the same set of field values in some (6) tables. I could do this by deleting the result of one subquery in every table (Solution 1), which would be redundant, because the subquery would be the same every time; so I want to store the result of the subquery in a temporary table and delete the value of each r...