sql

MySQL: Sum values in subqueries

I have information on school athletics, with tables for school, season, cashflow, and cashflow_group. I'm trying to query for all schools with cashflow in one or more given cashflow_groups within a user-specified range. I need to query multiple different categories in the same query. I'm having trouble. My query is below. The reason I d...

Delete records from multiple tables

Consider these several tables: tab1 ------- userid email address environment tab2 ------- ecode company policy tab3 ------- id pan no. dl no. Here tab1 is the parent table. I want to delete all the userid of tab1 from tab2 and tab3. Either userid will be in tab1 or tab2 or both. These tables are environment specific means environme...

Create a summary result with one query.

I have a table with the following format. mysql> describe unit_characteristics; +----------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------------+------------------+------+-----+---------+----------------+ | id ...

Dump SQL Server to XML?

In mysql, you can use mysqldump --xml to dump to XML. How do you dump a SQL Server database? Preferably to XML. ...

How to identify what control has focus, MS Access VBA

The question says it all. I have a listbox whose rowsource is change programmaticaly. If the control has the focus then I need use me.txtSearch.text when building the rowsource, otherwise I need to use me.txtSearch.value. How do I determine what control has the focus? ...

Normalize SQL table

Can we furthur Normalize this Sql Table Structue is Primary key is ID,Date,NAme,Type ID Date Name Type Value ----------------------------------------------------- 1 08/15/2010 Rating A+ 10 1 08/15/2010 Rating A- 10 1 08/15/2010 ...

Creating a SQL table from a comma concatenated list

I am running SQL Server and I have a stored procedure. I want do a select statement with a WHERE IN clause. I don't know how long the list will be so right now I have tried something as follows SELECT * FROM table1 WHERE id IN (@idList) in this solution @idList is a varChar(max). but this doesn't work. I heard about passing in table v...

Faceted Search in Coldfusion and SQL?

Hi guys, I'm working on a faceted search in Coldfusion and SQL. I've tried creating a query like this: SELECT * FROM Turbos WHERE PartNumber LIKE '%#trim(SearchCriteria)#%' OR PartDescription LIKE '%#trim(SearchCriteria)#%' AND (PumpingSpeed BETWEEN #minimum# AND #URL.speed#) AND InletFlange LIKE '#URL.inlet#' AND Beari...

Query count in .net

I'd like to do something similar to http://stackoverflow.com/questions/2116960/queries-count-for-page-in-asp-net-mvc - namely count the number of SQL queries executed in a particular request, and time them. The difference is, I don't have a standard method that all SQL queries are routed through - I need a method for intercepting all ca...

Does a lot of repeated sum(x) in different cols make a Select slower?

I have a really big table with dozens of columns and lots of rows. Lets call this table FT. Everyday I run a script that reads data from the FT table, perform some calculations, and update a smaller table (table FA) that I use to generate reports. The query that update FA is something like: INSERT INTO FA (A, B, C) (SELECT sum(X),...

Sql Query into excel

I have a sql query that pulls in form multiple tables, how can I run that query to import into an excel sheet? ...

How to efficiently store ever changing datasets (search results) for periodic reports

Hi all. I am having trouble coming up with a good way to store a dataset that continually changes. I want to track and periodically report on the contents of specific websites. For example, for a certain website I want to keep track of all the PDF documents that are available. Then I want to report periodically (say, quarterly) on the n...

MySQL, polish characters and duplicate insert statement.

Hi. I've got a problem with inserting two rows to table. The database is in UTF8. The problem seems to be connected to the collation. This statement works: insert into test(code,text) values('xx','aaa'); However when i try to add other row to the table: insert into test(code,text) values('xx','aąą'); it fails with duplicate entry e...

Using Hibernate to pull records based on the number of records in another table

I have a Users table that holds two different kinds of users (A and B). Type A users can have relationships with type B users (which is recorded in a Relationships table). The number of relationships that a Type A User can have with type B users is recorded in a field in another table. I want to have Hibernate return all type A users th...

Syntax Error in Create Function

This is one of the more confusing functions I've attempted. The logic works within a select statement, but I can't seem to create a user-defined function. Here's the error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimiter$$ creat...

Help creating a single SELECT statement for SQL Reports

I am trying to create an payment report which lists the sum in each account. The table is in SQL SERVER 2005 and it has the following table [Account]    [Amount]   [Type] 1111     10     C 1111     10     C 1111     15     D 1111     5     D 1112     10     C 1112     15     C 1112  ...

HQL: Fetch Join Collections from Eager Table

I have four tables: RootNode // Will return multiple root nodes SubNode // Will return one sub node per root node SubNodeChildren1 // Will return multiple for each sub node SubNodeChildren2 // Will return multiple for each sub node and a similar entity structure: RootNode -> SubNode -> SubNodeChildren1 -> SubNode...

migrating mysql to sql server 2008

i have a simple mysql database. it has 3 tables. here is the create statement for them: CREATE DATABASE `qcvalues` /*!40100 DEFAULT CHARACTER SET latin1 */ CREATE TABLE `batchinfo` ( `rowid` int(11) NOT NULL AUTO_INCREMENT, `datapath` mediumtext, `analysistime` varchar(50) DEFAULT NULL, `reporttime` varchar(50) DEFAULT NULL, ...

using IF in a SQL Server View

Hello, I have a view in SQL server that translates from one schema version to another. Currently, the view looks like this: SELECT newValue AS oldValue FROM dbo.MyTable The trouble is that, in the new schema, newValue is not nullable, so we set it to -1 to denote empty fields, but in the old schema, it was nullable. How can I do s...

How do I migrate a SQL MDF File to a production SQL Server? (ASP.NET)

I have an ASP.NET project that also uses a SQL MDF File. My target server is SQL 2008R2 or SQL Azure. I would like to know what deployment options I have as I migrate from DEV to PROD. In case it matters I'm not under any regulation to maintain PII or similarly private data. How do I move my test schema and perhaps data to production...