sql

PostgreSQL import problem - all tables but one import.

I have a reasonably sized postresql dump (around 270 mb) that I'm importing into a new database. All the tables import without issue except for one - the users table - and I'm neither sure what the problem is, nor what the best way to figure it out is. The tables after it import without error, so it's not as if it barf's on something and...

SQL - How to transpose?

I have something similar to the following table: ================================================ | Id | UserId | FieldName | FieldValue | =====+========+===============+================| | 1 | 100 | Username | John Doe | |----+--------+---------------+----------------| | 2 | 100 | Password | pass123! ...

SQL 2008 Replication subscriber DB's performance issues

I'm having an issue where a query ran on the publisher completes in 2-3 seconds while on the subscriber the same query takes 15-20 seconds to complete. I'm running Transaction replication. The difference between the Pub/Sub has to do with Indexes. I've created a script that rebuilds the indexes on the sub DB. We need to move the DB's...

Dot Net Nuke Installation

I am new to Dot Net Nuke. I downloaded and tried to install it onto Windows Server 2008. It installs to the point where it starts running scripts for the database. I choose SQL Server 2005/2008 as the database and put in the correct Database name and connection string with the correct credentials as well. It however fails after running a...

ExecuteNonQuery with parameters.

I have to process a file that contains a large number of sql statements. The issue is that the sql statement contain parameters. E.g. the file looks like this declare @var1 as nvarchar; set @var1 = 'value'; insert into table (field1, field2, field3) values ('value1', 'value2', @var1); repeates with the next set of three lines. I ...

Production Postgres query returning different values than local sqlite query

I have a query based on the answer to this question: http://stackoverflow.com/questions/2939061/handling-ties-when-ranking-from-the-highest-to-the-lowest/2939079#2939079 Given this dataset: Name | Score Mike | 5 John | 3 Mary | 3 Matt | 0 The following query returns a user array containing the correct values. User.find_by_sql("SELECT...

Refresh SQL Database

Hello! I use a SQL database in conjunction with my iPhone app. I uploaded it to the iTunes store, everything was working fine and the app was selling. Then, I added some data to the data base and uploaded the new binary to Apple. Apple approved the update. Here is the problem. When I update my app to the new version, the new records...

Restrict rows included in a SQL Server full text catalog

Is it possible to restrict the rows that are included in a FT catalog for a given table? For example, I would want only rows with IsActive=TRUE to contribute to the catalog and be searchable. Possibly this may reveal a lack of understanding on my part of FTS. I'm wondering whether there would be advantages in performance if the catalog ...

Select all data between two dates

Hello! It is necessary to choose values for some dates, how to do this I know, but there is one problem that does not work to solve. My table in MySQL: [User]. [Wins]. [DATE] # Ivan ....... 4 ..... 05/06/2010 # Ivan ....... 3 ..... 06/15/2010 # Ivan ........ 6 ..... 06/18/2010 # Ivan ........ 1 ..... 29/06/2010 The problem is that i...

Model clause in Oracle

I am recently inclined towards in Oracle jargon and the more I am looking into the more is attracting me. I have recently come across the MODEL clause but to be honest I am not understanding the behaviour of this. Can any one with some examples please let me know about the same. Thanks in advance ...

Finding overlapping dates

I have a set of Meeting rooms and meetings in that having start date and end Date. A set of meeting rooms belong to a building. The meeting details are kept in MeetingDetail table having a startDate and endDate. Now I want to fire a report between two time period say reportStartDate and reportEndDate, which finds me the time slots in wh...

SE: 'bcheck -y' anomaly

ISQL-SE 4.10.DD6 (DOS 6.22): My app has the following SQL script (CODE REVIEW) which my users exec at end of business day to reorg the transaction table: DATABASE dbfiles; UNLOAD TO "U:\UNL\ACTIVES.UNL" SELECT * FROM transaction WHERE trx_type IN ("E","I","C","P") ORDER BY trx_cust_fullname, trx_last_pymt; UNLOAD TO...

Oracle 10gR2 trigger error

I have Oracle 10gR2. I am trying to create autoincrement trigger. Here is the sample: CREATE SEQUENCE TEST_SEQ INCREMENT BY 1 START WITH 1 NOMAXVALUE / CREATE TABLE TESTER ( ID_TESTER INTEGER NOT NULL, VAL VARCHAR2(20) NOT NULL ) / CREATE OR REPLACE TRIGGER TIB_TESTER BEFORE INSERT ON TESTER FOR EACH ROW BEGIN SELECT TEST_SEQ.NEXTV...

Get the top row after order by in Oracle Subquery

I have a table student(id, name, department, age, score). I want to find the youngest student who has the highest(among the youngest students) score of each department. In SQL Server, I can use following SQL. select * from student s1 where s1.id in (select s2.id from student s2 where s2.department = s1.department order by age asc, sc...

How to combine result sets of a sql query?

I am having 5 checkbox with the food items like Chicken, fruits, vegetables, Snacks,.. like that. What i am trying to implement is when the user selects the checkbox items and clicks submit, it will search for the restaurants providing the selected items, Table will have 2 fields: restid, menu and the data is stored like this in the t...

Challenge: SQL check next record against previous

I have some data that needs to be validated, and while I have found a quick formula that works in excel I would like to find some SQL that would do the same so I can use it in my database as a check now and then. The data is simply this: ACACIA ST (KLN) | 1073 | 1149 | FAIL! | 76 ACACIA ST (KLN) | 1073 | 1151 | FAIL! | 78 ACACIA ST (KL...

How to notify C# code from Azure database

Hi, I am creating a WCF service (CALLER) for Azure. The service(CALLER) calls async methods of another third party service(EXTN). The third party service calls the callback methods of another WCF service (LISTNER) hosted by me on Azure. CALLER enter the service details in the databsae with status = PENDING. In the callback service (LIS...

how to count net amount according to month

hi.i'm using this query SELECT EXTRACT(month from doc_date) columnno, sum(net_amt_rm) sum_amt, max(doc_date) ddate FROM POSM WHERE EXTRACT (year from doc_date) = '2010' GROUP BY EXTRACT(month from doc_date) UNION //union no 2 SELECT EXTRACT(month from doc_date) columnno, sum(net_amt_rm) sum_amt, max(doc_date) ddate FROM CIM ...

Ruby On Rails: How to run safe updates

I'm using RoR and I want to do concurrency safe update queries. For example when I have var user = User.find(user_id) user.visits += 1 I get the following SQL code: SELECT * FROM Users WHERE ID=1 -- find user's visits (1) UPDATE Users SET Visits=2 WHERE ID=1 -- 1+1=2 But if there are several queries taking place at the same time, ...

mysql query, two select

Hi, As soon as I apologize because I do not know or be able to explain exactly trouble. How get value from table user_address. how to pass user ID in the second "select". select id, name, age, (select address from user_address where user_id = ??user.id ORDER BY address_name LIMIT 1) AS address from user ...