sql

Help Me With This MS-Access Query

I have 2 tables: "products" and "pieces" PRODUCTS idProd product price PIECES id idProdMain idProdChild quant idProdMain and idProdChild are related with the table: "products". Other considerations is that 1 product can have some pieces and 1 product can be a piece. Price product equal a sum of quantity * price of all their pie...

mysql group by and count rows problem

hello let's say mysql is something like this select x,y from xx group by y i want to know how many rows that select will get, i tried to use count but it will n't return all results since i'm using group by. how to do that? Thanks ...

SQL 2008 Database tuning advisor won't start

For some reason I can't get DTA to connect to my development machine. It connects to a remote DB just fine but when I point it to my dev machine I get an error saying: Failed to initialize MSDB database for tuning (exit code: -1073741819). I'm pretty sure it's not a permissions issue since I've used profiler to capture what it's doing ...

Explanation of converting exporting an XML document as a relational database using XSLT

I would like to better understand the basic steps needed to a take an XML document like this Breakfast Menu... <?xml version="1.0" encoding="ISO-8859-1"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup</d...

Compare datatime field with current datetime in MySQL

I have something like that: to_days(now()) < to_days(birth) It work but instead of comparing days I was to compare the time too. Is there a similar function? ...

Using a .MDF SQL Server Database with ASP.NET Versus Using SQL Server

I'm currently writing a website in ASP.NET MVC, and my database (which doesn't have any data in it yet, it only has the correct tables) uses SQL Server 2008, which I have installed on my development machine. I connect to the database out of my application by using the Server Explorer, followed by LINQ to SQL mapping. Once I finish deve...

How to make a Generator for Stored procedure ?

i try to write a generator or i want to write all stored procedures(SP) in C# side. how can i do that? 1) writing a sp generator OR 2) Coding all sps via C# OR 3) Writing All data process (SP) via Linq which one is best or your advise? ...

Best approach to optimize a record history database

I have a database that keeps record history. For each update to a record, the system will "deactivate" the previous record (along with all it's children), by setting the "Status" column to "0". Now it's not a problem yet...but eventually this system is going to have a lot of records, and history is more important than speed right now. B...

Install client with system.data.sqlclient.dll

I am install an c# winforms app 3.5 to a client that references a mdf file that will in SQL server express. I installed .net 3.5 sp1 so the latest .net data providers for SQL server should be there?? I am getting an error for system.data and the above dll. What are the dependencies am I missing? ...

Displaying Multiple SQL Fields as a Single Field

I have the following tables: CREATE TABLE title ( booktitle VARCHAR( 60 ), title_id CHAR( 6 ), au_id CHAR( 11 ), PRIMARY KEY (title_id) ) create table authors ( au_id char(11), au_lname varchar(20), au_fname varchar(20), phone varchar(10), address varchar(30), city varchar(20), state char(2), zip char(5)); I ne...

SQL indexing on varchar

I have a table whose columns are varchar(50) and a float. I need to (very quickly) look get the float associated with a given string. Even with indexing, this is rather slow. I know, however, that each string is associated with an integer, which I know at the time of lookup, so that each string maps to a unique integer, but each integer...

Changing the indexing on existing table in SQL Server 2000

Guys, Here is the scenario: SQL Server 2000 (8.0.2055) Table currently has 478 million rows of data. The Primary Key column is an INT with IDENTITY. There is an Unique Constraint imposed on two other columns with a Non-Clustered Index. This is a vendor application and we are only responsible for maintaining the DB. Now the vendor has...

Proper way to structure a Sync Framework DAL

I am creating a WPF app that needs to allow users to work in a temporary disconnected state and I plan to use a Local Database Cache. My question's are about my data access layer. Do you typically create the whole DAL to point at the Cache or both and create a switching mechanism? Is Entity's a good way to go for my DAL against the ...

How to write my own global lock / unlock functions for PostgreSQL

I have postgresql (in perlu) function getTravelTime(integer, timestamp), which tries to select data for specified ID and timestamp. If there are no data or if data is old, it downloads them from external server (downloading time ~300ms). Multiple process use this database and this function. There is an error when two process do not fin...

SQL Group By and Join

I feel totally stupid. I'm rusty with my sql. I have two tables, Message and MessageThread. Each message belongs to one MessageThread using ParentTHreadID as a Foreign Key. You probably can see where this is going. Well, I want to do something like this. I want to get columns from both tables, messages and threads, but where the mes...

SQL query on table that has 2 columns with a foreign id on the same table

Hello all, I have a table let's say in the form of: match(id, hometeam_id, awayteam_id) and team(id, name). How do I build my SQL query in order to get a result table in the form of (match_id, hometeam_name, awayteam_name), since they both (hometeam_id, awayteam_id) reference the same table (team)? Thank you ...

Specify rowterminator when creating a file with SQLCMD

How do you specify the the row terminator when outputting query results using sqlcmd? bcp is not an option. sqlcmd -E -s" " -Q "Select * From SomeTable" -o C:\Output.txt -W What is the default row terminator? ...

Problems getting foreign keys working in MySQL

I've been trying to get a delete to cascade and it just doesn't seem to work. I'm sure I am missing something obvious, can anyone help me find it? I would expect a delete on the 'articles' table to trigger a delete on the corresponding rows in the 'article_section_lt' table. CREATE TABLE articles ( id INTEGER UNSIGNED PRIMARY KEY...

Comparing RPG to C# and SQL.

In an RPG program (One of IBM's languages on the AS/400) I can "chain" out to a file to see if a record (say, a certain customer record) exists in the file. If it does, then I can update that record instantly with new data. If the record doesn't exist, I can write a new record. The code would look like this: Customer Chain CustFile ...

Hosting SQL at remote location?

Hey guys, My OSCommerce site includes a separately programmed feature for which I use SQL tables. I've decided to host its tables on a remote site offering free SQL accounts. I'd like to know if there could be any disadvantages to this approach. Thanks Syd ...