Most Popular
1500 questions
23
votes
3 answers
Determine percentage from count() without cast issues
I'm trying to run the following query to provide the % of rows in my patients table that have a value the refinst column. I keep getting a result of 0.
select (count (refinst) / (select count(*) from patients) * 100) as "Formula"
from…
user3779117
- 331
- 1
- 2
- 4
23
votes
1 answer
log_min_duration_statement setting is ignored
I am running Postgresql 9.1 on Ubuntu. Exact Postgresql version is 9.1+129ubuntu1 as my package manager shows.
I have 2 databases that are actively in use and they are used from a remote server.
I wish to log queries that have a long execution time.…
Mp0int
- 459
- 1
- 6
- 14
23
votes
3 answers
MySQL database freezing after 'use'
I recently made a rather stupid mistake and corrupt my Ubuntu installation. To resolve it, I booted with a live cd and copied the database files over. However, now I have copied the folders from the old installation into the new one, whenever I…
Matthew Haworth
- 395
- 1
- 3
- 7
23
votes
8 answers
How do you kick users out of a SQL Server 2008 database?
We need to do a restore, and cannot because other users are connected.
We thought we had disconnected every process, but apparently not.
How can we, from Management Studio, kick off everyone else so we can do this backup?
Daniel Williams
- 936
- 4
- 11
- 19
23
votes
9 answers
Is there a reason to use extremely abbreviated table names?
We're using a database setup from a vendor's application that has horrifically hard to read database table names, and no documentation on what is stored where. I can see why one might want to obfuscate their table structure in a proprietary app, but…
Ben Brocka
- 2,063
- 6
- 28
- 38
23
votes
2 answers
Why are the plans different if the queries are logically alike?
I wrote two functions to answer Day 3's first homework question from Seven Databases in Seven Weeks.
Create a stored procedure where you can input a movie title or actor's name you like, and it will return the top five suggestions based on either…
Iain Samuel McLean Elder
- 2,328
- 4
- 25
- 39
23
votes
2 answers
Is it possible to view LRU-K values in SQL Server?
In SQL Server's sys.dm_os_memory_cache_entries, it is possible to view both the original cost of an entry in the cache as well as the current cost of the cache entry (original_cost and current_cost respectively). The DMV sys.dm_os_buffer_descriptors…
anon
23
votes
5 answers
Should Query Tuning be Proactive or Reactive?
As a software developer and an aspiring DBA, I try to encorporate best practices when I design my SQL Server databases (99% of the time my software sits on top of SQL Server). I make the best possible design prior to and during development.
But,…
Thomas Stringer
- 42,224
- 9
- 117
- 154
23
votes
4 answers
Is there a way to generate table create script in TSQL?
Is there a way to generate a create script from an existing table purely in T-SQL (that is without using SMO, since T-SQL does not have access to SMO). Let's say a stored procedure that receives a table name and returns a string that contains the…
Andrew Savinykh
- 1,305
- 5
- 14
- 28
23
votes
1 answer
Upgrade SQL Server 2000 database to 2008 R2 and enable new features
I have recently upgraded SQL Server 2000 database to 2008 R2.
What I did was:
Shutdown SQL Server 2000 (express) service on old machine,
Move datafiles (mydatabase.mdf and mydatabase.ldf) to new machine,
Run SQL Server Management Studio…
saelic
- 345
- 1
- 3
- 8
23
votes
5 answers
Location of the mdf file of the database
I have a database Project. My problem is where can I find the .mdf and _log.ldf of my database so that I can transfer my database to another user. I am using Microsoft SQL Server 2008 Management Studio
My Ssms.exe is stored in this…
Shreyas tg
23
votes
7 answers
How check that the Oracle Database is up?
For our application we have a configuration file for connecting to the Oracle database (URL, username, password).
The application takes 2-5 minutes to start. If there is something wrong with database I see this in logs, but I have to wait 2-5…
Eugene
- 231
- 1
- 2
- 3
23
votes
3 answers
Why is `SELECT @@IDENTITY` returning a decimal?
I'm using Dapper to execute the following query against a SQL Server 2008 R2 Express instance from a ASP.NET MVC 3 (.NET 4.0) application.
INSERT INTO Customers (
Type, Name, Address, ContactName,
ContactNumber, ContactEmail,…
Greg B
- 559
- 2
- 6
- 15
23
votes
3 answers
How to determine master in mysql master-slave
I am setting up MySQL Master-slave replication and I am trying to figure out how to handle the failover situation where I promote the slave to master (in the event that the master goes down).
My application server needs to direct all writes to the…
Ethan Hayon
- 365
- 1
- 3
- 8
23
votes
2 answers
What are Measures and Dimensions in Cubes
I'm new to Microsoft SQL Server Business Intelligence and Analysis Service (but I've been programming for years with SQL Server). Can any one describe Measures and Dimensions in Cubes in simple words (If it's possible with images)?
DooDoo
- 203
- 1
- 3
- 12