sql

SQL clustering or VM images

We currently have a failover sql cluster with two nodes. For a new large project which we have determined to be business critical, our development team is requesting a new 2 node failover sql cluster. Our server department has responded saying that they do not want to implement a cluster for us, and instead employee multiple virtual ...

Update rows in a table with many columns

I have a table (several actually) that contain a lot of columns (maybe 100+). What's best performance-wise when updating rows in the table, if only a few columns have been changed. To build the UPDATE statement dynamically only updating the changed columns. To build a parameterized UPDATE-statement containing all columns, including tho...

SQL returning 0 records / date problem?

The SQL below is returning 0 records when I know there are records that match - I think it's the date causing me problems. Here is the SQL: exec sp_executesql N'SELECT * FROM [dbo].[QuizAnswersCompleted] WHERE [dbo].[QuizAnswersCompleted].[QuizProfileID] = @QuizProfileID0 AND [dbo].[QuizAnswersCompleted].[DateCompleted] = @DateCom...

Why might IDbCommand.ExecuteReader() fail when IDbCommand.ExecuteScalar() succeeds?

I have some C# code that dynamically generates an SQL query and executes it via IDbCommand.ExecuteScalar(). This works fine; there's exactly one result that matches my query in the DB, and that result is always returned. But just recently, as the first step in a refactoring to support multiple matches in the DB, I replaced the call to ...

Sub queries and sorting? (ORDER BY)

So my syntax is apparently correct in all three cases (PostgreSQL isn't grousing about anything) but the results come back in the same order with all three of these queries. Even stranger when I add/remove DESC from any of the following it has no impact either. Is it possible to sort results based on elements of a sub query or not? So...

How to set connection pool to 100 in sql server 2005 instance

How to set connection pool to 100 in sql server 2005 instance ...

Database design to hold a person's information that changes with time?

We use a third-party product to manage our sports centre membership. We have several membership types (eg. junior, student, staff, community) and several membership statuses (eg. annual, active, inactive, suspended). Unfortunately the product only records a member's current membership type and status. I'd like to be able to track the way...

How to set bufferpool to 8K on SQL server 2005 database

How to set bufferpool to 8K on SQL server 2005 database ...

Why does $dbh->do('VACUUM') fail with Perl's DBD::SQLite?

I want to do VACUUM at a certain time on a SQLite database under Perl, but it always says DBD::SQLite::db do failed: cannot VACUUM from within a transaction So how do I do this? my %attr = ( RaiseError => 0, PrintError => 1, AutoCommit => 0 ); my $dbh = DBI->connect('dbi:SQLite:dbname='.$file'','',\%attr) or die $DBI::errstr;...

C# - Quickest way to run SQL on a multidimensional array.

I want to take a table as represented by a multidimensional string array (column names in another array) and use a SQL SELECT statement to get a subset of rows. The Catch: - the table is input by the user (different table each time) - the SQL is also input by the user Do I need to: 1) Create a table in SQL 2) Populate the table in SQ...

What is the impact of setting up an index on varchar field?

I've got a table with approx 7 million rows of data. The schema is something like: ID - int (Primary Key) Name - Varchar(250) Null ... I want to set an index up for the Name column to speed up searches. e.g Select * from table where name = 'ABC' But what is the impact of setting up an Index on a varchar field? Index size? Does ...

how to join or Union result of 2 sql queries in single result set

i have 2 tables(result of two separate SQL queries and this result will be contained by List<Object> where each object represents 1 row of the database ) Table_1 Dimension_1 Dimension_2 Fact_1 Table_2 Dimension_1 Dimension_2 Fact_2 I want to join these two result in the RESULTSET AS Table_Resultant Dimension_1 Dimension_2 Fac...

DESCRIBE in a FROM subquery

Hi Guys, Is it possible to have a DESCRIBE table clause inserted as a subquery in FROM of a SELECT clause in MySQL? Further, is there a way to enforce a WHERE like condition on a DESCRIBE output? EDIT: Basically, I have a table with a large number of columns and I want to pull out and act upon the particulars of only one column. ...

How can I get this mysqli database class working?

I'll cut right to the chase. All I can achieve at this point with this class is a database connection. I am unable to make a query. Can you show me exactly how to get this working and/or show me how to recode it in a better way. <?php class database{ public $dbHost = ''; public $dbUser = ''; public $dbPass = ''; public $dbName = ''; p...

In SQLite3, will this select statement benefit from two indexes?

I am using a DBD::SQLite in memory database. I have defined the following indexes for a table: CREATE INDEX x ON ss (a, b); CREATE INDEX y ON ss (c, d, e, o); Will the following select statement use these two indexes? SELECT f, g FROM ss WHERE a = ? AND b = ? AND c = ? AND d = ? AND e = ? And, I should only make indexes on those co...

MySQL : selecting all corresponding fields using MAX and GROUP BY

I have this table : And I would like to make a request that would return for each deal_id the row with the highest timestamp, and the corresponding status_id. So for this example, I would have returned 2 rows : 1226, 3, 2009-08-18 12:10:25 1227, 2, 2009-08-17 14:31:25 I tried to do it with this query SELECT deal_id, status_id, ma...

Reducing Size Of SQL Backup?

I am using SQL Express 2005 and do a backup of all DB's every night. I noticed one DB getting larger and larger. I looked at the DB and cannot see why its getting so big! I was wondering if its something to do with the log file? Looking for tips on how to find out why its getting so big when its not got that much data in it - Also how t...

adding lock option to Create Table statement in Sql Server 2005

I am busy creating tables in Sql Server from a Sybase database. In the Sybase database when the tables are created an option 'lock allpages' was used, how can I replicate this when creating the tables in Sql Server 2005. ...

How do I set query field formats at vba runtime

I am creating a Crosstab query at runtime with the option of using a summary type of "SUM" or "COUNT". If I set Sum, then I want an output format of "$#,##0.00", and if it is Count, then I want an output format of "#,##0". There are lots of discussion questions setting a tableDef Field property to format output, but there is nothing th...

Inserting a date into an access db in vb

Hi, Im a little stuck and I dont know what im doing wrong. I want to insert the current date into a MS Access database in VB. The part of the code im having trouble with is: SQLString = "INSERT INTO Sales(DateSold) VALUES (" SQLString += Date.Today & ")" The type in the database is date and is dd/mm/year. Thanks in advance for the...