sql

Select from hundreds of tables at once (.mdb)

We have .mdb file with hundreds of tables: Lesson1, Lesson2, Lesson3, Lesson4, etc. All tables have the same structure: Lesson<n> ---------------- slide_id name description status created_date created_by updated_date updated_by What SQL statement would generate a result like this: | table_name | slide_id | name ...

Transpose a row into columns with MySQL without using UNIONS?

I have a table that is similar to the following below: id | cat | one_above | top_level | 0 'printers' 'hardware' 'computers' I want to be able to write a query, without using unions, that will return me a result set that transposes this table's columns into rows. What this mean...

Why is using a parameterized query to insert data into a table faster than appending the values to the query string?

Why is using a parameterized query to insert data into a table: string queryString = "insert into product(id, name) values (@id, @name)"; faster than appending the values to the query string: string queryString = "insert into product(id, name) values (" + _id + ", " + _name + ")"; ? When I use the command in a loop to insert 10K r...

What's the best practise to write SQL to get data as follow ?

Dears I have the following two table in SQL server 2005 DB 2- "UserInfomration" ---> ( ID (auto) , Name , Gender ( bit ) ) 1- "Competitors" ---> ( Id (auto) , UserID ( FK from UserInformation.ID ) , Status ( tinyint) i want to make a stored procedure that return data as follow Status - Male count - Female Count      1              ...

How to find list of all tables in Access Database matching certaing format in Delphi

I need to compute a list of table names in a given database (MDB format), which have certain format (for example which containt DateTime field "Date Applied"). How can I do it? Note: I am using Delphi 7, ADO components, Microsoft JET 4.0 to connect to MDB type Database. ...

SQL select statement string concatenation

Can something like this be done with a select statement: SELECT col1, concat(col2 + ' ') FROM .... GROUP BY col1 I know i can use count(col2) or sum(col2) for integers but is there a function for concatenating if the type is nvarchar or nchar? ...

SQL Server and Calculated Fields?

So I'm creating an app that with users who can earn "points" in many different ways. Some of these point accruals occur because of their profile, actions they've taken, etc. (i.e. spread across multiple tables). I don't want to manually add points in a field when certain actions occur because I want to ensure number consistency. I would...

How to find columns count of any table in any database from sql server master database?

If I know the database-name and table-name, how can I find columns-count of the table from sql server master database? What is the fastest way to find the columns count of any database-table? What do you think about the performance of this query? select count(*) from SYSCOLUMNS where id=(select id from SYSOBJECTS where name='Categorie...

LEFT JOIN for current row in primary table

This is the question about JDBC. I have next task. I'm iterating through rows from table A and for some current row I want to execute some query against table B in context of current row from A. For example, if I have some query like SELECT B.description FROM A LEFT JOIN B ON A.ID = B.refId then I want to get all results where B.refI...

How to convert Sql query with inner join statement to sql query with Where statement(no inner join in statement)

I have generated the following sql query code in access using the Qbe and converting it to sql.However, i want proof that i did without help so i intend to take out all inner join statements and replace them with the WHERE statement. How do i work it out. Please explain and provide answer. thank you. SQL Query: SELECT Entertainer.Ente...

sql grouping... thing

I have this data: ID Country City Type Qty SomeDate SomeDate1 SomeDate2 1 Canada Ontario Type1 1 01/01/2009 02/02/2009 03/03/2009 2 Canada Ontario Type2 1 01/01/2009 02/02/2009 03/03/2009 3 Germany Berlin Type1 1 03/01/2007 02/01/2008 04/03/2006 4 Germany Berlin Type1 3 ...

How to Checkpoint while using For Each Loop container in SSIS

How can I use Checkpoints while I am using For Each Loop containers in an SSIS package? Whenever I try and rerun the package it starts from the beginning of the foreach loop container instead of from where it failed. The checkpoint seems to have trouble with for each loop containers. I created a table insert to help me identify where ...

Query a list of names from one table that appear in a field in a different table

I want to query a list of names from one table that appear in a field in a different table. Example: table1.title>Tiger Woods Cheats, Tiger Woods Crashes, Brad Pitt is Great, Madonna Adopts, Brad Pitt Makes a Movie table2.names>Tiger Woods, Brad Pitt, Madonna So those are the two tables and values. I would like to write a query that...

SUM(a*b) not working...

I have a PHP page running in postgres. I have 3 tables - workorders, *wo_parts* and part2vendor. I am trying to multiply 2 table column row datas together, ie *wo_parts* has a field called qty and part2vendor has a field called cost. These 2 are joined by *wo_parts.pn* and part2vendor.pn. I have created a query like this: $scoreCostQuer...

SQL Server locks - avoid insertion of duplicate entries

After reading a lot of articles and many answers related to the above subject, I am still wondering how the SQL Server database engine works in the following example: Let's assume that we have a table named t3: create table t3 (a int , b int); create index test on t3 (a); and a query as follow: INSERT INTO T3 SELECT -86,-86 WHERE NO...

SQL query's organisation, transforming url into title from db

Hi everyone! I currently have a site with multiple articles being user-generated as content. On each new post, there is a hidden $getcurrentpageurl variable. When a user is reading a post (x), a form button saying "respond to this post" sends the user to a submit form, in which a hidden field catches the posted $getcurrentpageurl, and i...

Display SQL Server table in DataGridView

I think it's kind of noob question but I'm new to SQL Server in .NET and I've already lost several hours on this... I started new project, inserted DataGridView on empty form and as Data Source I chose Add->Database and I created new SQL Server Database File. I called it db.mdf. Now I get DataSet named dbDataset and BindingSource named ...

how to develop c#.net desktop base software?

i have to develop desktop base software in C#.Net which only produces reports and that reports can be export to any format. that software will be dump into CD/DVD and distributed to all clients and they will install it in their PC (Stand Alon PC). and that will be installer, client can install it himself. My problem is which database i ...

Why won't DB2 use my MQT table?

I've created a user-maintained MQT (Materialized Query Table) in DB2 9.7 (not yet fixpack 1). It's a simple grouping of the main fact table. But my queries aren't being rewritten to hit it. Here's what I've tried: Created the MQT with ENABLE QUERY OPTIMIZATION and MAINTAINED BY USER characteristics Also included REFRESH DEFERRED & D...

Single or multiple mysql rows? (shopping basket)

I am currently creating a custom e-commerce site (in php, but that's not really relevant for this question). I have just got to creating the shopping basket, and cannot decide between the following 2 options: option 1: Basket table: id user items In this option, I would have one row per user, with all of the items and quantities st...