sql

Is there any way to know what cache size is needed?

I am using mysql as a db. Is there any formula for determining the cache size needed to cache the results? Thanks ...

Fileupload to varbinary FileStream Field ASP.net

Hello I want to upload files from fileupload control and save them as varbinary Filestream in the database. First of all, does this make sense? Would you recommend this? Then, how does it work? I want to be able to upload Imagefiles as well as .doc and .xls. so when i have uploaded a .xls, how would i save it to the Database(i'm goin...

How much of this task can/should be done in SQL?

I have a database where I would like to construct a result that match my indata. Explanation of examples: "Indata" is a row with criteria for the filter in step #1, see below. "Results after filter #1" is the rows left after step #1 "Results after filter #2" is the rows left after step #2 "Print for indata 1" is the end result, presenti...

Easy way to find out how many rows in total are stored within SQL Server Database?

I'm looking for easy way to count all rows within one SQL Server 2005/2008 database (skipping the system tables of course)? I know i could use SELECT COUNT (COLUMN) FROM TABLE and do it for each table and then add it up but would prefer some automated way? Is there one? ...

Best Approach for Storing One-Many Relationship - Practical Example/Dilemma

I need to model an idea which can be broken down and thought of as follows: BookDetails BookPrices The problem here is that you can have many prices for books and these prices are likely to change. Here's an example BookDetails: ----------------- ID Name 1 Harry Potter… This is easy enough. Where it is more interesting is t...

ODBC Remote connectioon problem

Hi there. I'm trying to set a connection through ODBC to an SQl Server Express 2005 instance the following connection string is working fine when I use it on the same machine Conn string: "DSN=_Vendas;TrustedSecurity = yes;"; I have an ASP.NET application that needs to use the same connection remotel, and this fails Exception: ERROR ...

SQL Syntax with AS and ORDER BY in nested queries

I have a query with the following syntax: select x.a as a, x.b as b, x.c as c from (select distinct a from foo order by y) as x left join zzz.... left join yyy...; I want to now put in an order by into the outer select statement. attaching it to the end - it doesn't like the syntax, and putting it before the as is apparent...

Selecting rows - unique field as criteria

Having this table: Row Pos Outdata Mismatch Other 1 10 S 0 A 2 10 S 5 A 3 10 R 0 B 4 10 R 7 B 5 20 24 0 A 6 20 24 ...

Interpreting coded field in SQL

Having this table, I would like to find the rows with Val fitting my Indata. Tol field is a tolerance (varchar), that can be either an integer/float or a percentage value. Row Val Tol Outdata 1 24 0 A 2 24 5 B 3 24 10 C 4 32 %10 D 5 32 1 E Indata 30 for example should match rows 3 (24+10=34) and 4 (3...

sql query with multiple checkboxlist selected

I have a complex query that includes some dynamic sql which partially depends upon a checkboxlist. Here's the part that has me stumped right now (brain fart?). Simple example: Table A (id, name) Table B (id, Aid, Cid) Table C (id, color) So lets say Table A has: 1, Bob 2, Tim 3, Pete and Table C has: 1, Red 2, Blue 3, Green Now...

How do I go about handling the shifting of news articles in regards to main, featured, and category areas?

Consider a template such as this ( questions posted below ): Let's say I posted an article about the Superbowl and tagged it in the Sports category. In my articles table I have a flag for featured or not, and a flag for main article. So if I check the main flag it shows up as the main article. If I post another main article a day late...

MySQL Trigger only for a certain mysql user

I'm trying to find out if a specific MySQL User is still in use in our system (and what queries it is executing). So I thought of writing a trigger that would kick in anytime user X executes a query, and it would log the query in a log table. How can I do that? I know how to write a query for a specific table, but not for a specific us...

how to display a particular field first and remaining next in MYSQL

I have a table structure like : ID, Test_ID, Verdict, PATH, Last_Status, Present_status, Remote_location,TestCase I want the result to be displayed starting with TestCase But I do not want to mention all the fileds particularly. Is there anything like select TestCase,* from Table order by TestCase` ? Basically the result sho...

Database EAV Pros/Cons and Alternatives

I have been looking for a database solution to allow user defined fields and values (allowing an unlimited number). At first glance, EAV seemed like the right fit, but after some reading I am not sure anymore. What are the pros and cons of EAV? Is there an alternative database method to allow user defined attributes/fields and values?...

Good Way To Handle XML Change

Our system stores XML strings in a database. I've recently had to change the Properties on a Class, and now when an XML string gets deserialized it will throw an exception. What is the best way to handle this change? Look for the Node in the application code using XPATH or LINQ, or change the xml string in sql database (ie do a mass u...

SQL Server - join or subquery in update statements?

Is there a reason to use one of these UPDATE statements over the other with regards to performance? UPDATE myTable SET fieldx = 1 FROM myTable AS mt , myView AS mv WHERE mt.id = mv.id UPDATE myTable SET fieldx = 1 WHERE id IN ( SELECT id FROM myView ) ...

How to vary connection string for different work locations

I am working on a C# 4.0, WPF 4.0, SQL 2008 project and I do work at home and in the office. I just setup SubVersion using Visual SVN per the recommendations found in other questions. The problem I am having is the connection string for the database is different for each location. At home I have the database on my dev system, in the off...

mysql conditional insert on duplicate update - multiple records

How can I use the ON DUPLICATE UPDATE with a multiple value INSERT? INSERT INTO tbl_name (key_id,field1,filed2) VALUES (1,2,3), (1,5,6), (1,8,9); ...

MySQL: Can I constraint column values in one table to values in a column in another table, by DB design only?

Example: Table "persons", Column "surname" may only contain values predefined in Table "names", Column "surnames", which would contain a collection of surnames acceptable for the purpose. Can I achieve this by design (i.e. without involving any validation code)? On a MyISAM table? No? On InnoDB? Thank you. ...

Query to search tree in database

I have a table in my database representing a tree. The data is stored using nested sets. I want to write a query to search the tree and return just the nodes that match a pattern, along with their ancestors and descendants. This is what I have come up with so far. SELECT DISTINCT Node, Parent, Description FROM Hierarchy INNER JOIN ...