DO NOT USE this for questions targeting Microsoft SQL Server, use the tag sql-server instead. "SQL" is an acronym for "Structured Query Language", it is used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. ...

learn more… | top users | synonyms (1)

2
votes
1answer
45 views

Convert Log table days in a state

This is simplified but represents the problem I am trying to solve. We have a table containing 5-10 million rows in a format similar to the following... Input Table Date Item Moved to Box Oct-1 ...
-1
votes
1answer
222 views

Selecting the right data type for text

In my database, I have columns that should contain text pieces. What is the best data type used for texts in SQL? How can I show that text as a numbered or bullet list? Can I search for a certain ...
1
vote
9answers
1k views

Is there any way to run the definition of multiple stored procedure at a time?

I have created the definition of more than 200 stored procedures. My problem is that I have to execute them on a different server and on a different database. The process which I am following is that ...
2
votes
2answers
230 views

Implementation Idea for login structure (login id with two different tables)

I am creating a sample web application for a business and I am stuck at the login implementation. There is supposed to be two different users (login types?). I will have employees and customers. I ...
6
votes
2answers
3k views

How do I query to pull all data in row based MIN and MAX service date?

I'm very new to Oracle SQL especially in the Pentaho report builder. It lets you do some things and block others. PL/SQL is not available so I must do this in a query. I need to be able to pull ...
0
votes
1answer
95 views

get query from 4 tables

I have three tables: User (Table) - Email - Moblie - User_id Invoice_product (Table dbo.payware_factor_product ) - invoice_id - Product_id Invoice (Table dbo.payware_factor ) - User_id - Mobile - ...
2
votes
1answer
353 views

Move DTC from one node to another in Windows 2003 R2 Clustering

I have a Windows 2003 R2 two node cluster that is running MSDTC as part of the Cluster Group. Is it possible for me to change the current MSDTC owner without moving the entire Cluster Group to the ...
0
votes
3answers
580 views

SQL Server 2008 R2 Remote Connection issue

I have installed SQL Server 2008 R2 in mixed mode, but currently issue is I can't use SQL through ip nor ip with port, even I have enabled TCP/IP and open port in firewall too. I tried to telnet ...
6
votes
2answers
18k views

How can I get the actual data size per row in a SQL Server table?

I found this script sql-server-2005-reaching-table-row-size-limit that seems to return the row size per defined data type lengths. I need a script that would give me all the rows in a table that ...
4
votes
3answers
142 views

How to join the updated result set of multiple servers

I have got 4 different servers and I want to get the free diskspace of all those in a single output. using xp_fixeddrives we will get the free space in each drive . Its not possible to get into all ...
3
votes
2answers
571 views

Help with a multi-language medical database

My project is to design a database for medicines in many countries. Medicines have various criteria like composition, price, manufacturer. Database will be multi-language; related to each country. ...
5
votes
4answers
2k views

SQL Server DB restore fails

I am trying to do a SQL Server database restore using this T-SQL code: ----Make Database to single user Mode ALTER DATABASE xyz SET SINGLE_USER WITH ROLLBACK IMMEDIATE ----Restore Database RESTORE ...
2
votes
2answers
1k views

What is a 'Target Server' in a SQL Server Agent Job?

Can someone explain what a 'Target Server' is in this instance. Also, what it means to "Target Multiple Servers"?
18
votes
3answers
3k views

Why does ANSI SQL define SUM(no rows) as NULL?

The ANSI SQL standard defines (chapter 6.5, set function specification) the following behaviour for aggregate functions on empty result sets: COUNT(...) = 0 AVG(...) = NULL MIN(...) = NULL MAX(...) = ...
1
vote
3answers
7k views

How to import Sybase .db file into SQL Server database?

I've been given a Sybase .db file by a client and I need to import that into a new SQL Server database so that I may see the data as well as the tables and their relationships, any ideas on how that ...
1
vote
1answer
768 views

How to import big sql file in Phpmyadmin

I am having a big sql file( 16mb) and all i need is to upload it to the Phpmyadmin to work with it in my localhost. I'm a newbie here in Php/MySql and i want to know about the details regarding the ...
6
votes
2answers
8k views

Allowing Foreign Key to be Null

I'm trying to create a relationship between two tables where one column in TABLE A is the foreign key for a column in TABLE B. However, there is one row in TABLE B that is currently null in that ...
6
votes
1answer
122 views

What happens behind the scenes when adding a nullable column in SQL Server?

This question came up today. When you add a column that accepts null values to the end of a table what exactly happens? Does the table get fully rebuilt similar to what happens when you change column ...
6
votes
1answer
2k views

SQL Server transaction log file refuses to grow

Problem: I have a SQL Server database sitting on a 1 TB drive. The log will not grow past 5 MB even when the MAXSIZE is set much larger than 5 MB. Error received: The transaction log for database ...
0
votes
1answer
53 views

Mark exported rows as exported

I need to write an export module which marks exported rows as exported. We currently run SQL Server Express 2012, but may switch to Oracle, so I need a client-side approach. We are currently using ...
2
votes
1answer
46 views

In real terms, how much effect does a bad fillfactor have on performance?

There's a storm brewing, or maybe I should say firestorm. A customer has recently implemented SQL Server 2012 Always On but that's not the most important bit. A list of fires to be put out has been ...
2
votes
2answers
835 views

Closed loops in database model, does it affect the performance?

I have heard that having loops in the database relational model should be avoided. From what I can think of, it is not a good practice, because there will be more than one different pathes to get the ...
2
votes
3answers
5k views

Managing SQL Server MDF and LDF file size

I am new to SQL Server and don't fully understand its architecture. I've looked around, Googled, asked around but found no simple (understandable) answer to the problem. I'm not even sure if it is ...
1
vote
4answers
4k views

Select from linked server to local server causing waits on both sides

The queries in question are here: http://pastie.org/4833351 Run individually, each of these queries runs through (albeit slow). Run as a group, it just sits there, showing either OLEDB waits on the ...
2
votes
1answer
3k views

How do I completely remove MySQL from a 64-bit windows 7 machine?

I'm new to MySQL and struggling to find a version and workbench which is stable on my 64 bit Windows 7 machine. I've decided to attempt to completely remove MySQL from my machine and to restart the ...
2
votes
2answers
1k views

Running a CTE query in a loop using PL/pgSQL

I'm trying to execute query that is repeatedly called in a loop using plpgsql -the loop iterates over another table (named coordinates) that contains top left and bottom right latitude/longitude ...
1
vote
0answers
135 views

Use of hash functions in group by?

I'd use a listagg() to generate a list of components a certain customer has and compare it to another list generated the same way somewhere else to detect inconsistencies. The problem is that ...
1
vote
2answers
116 views

How can I improve this query

I have the following table: CREATE TABLE `twitter_relationships` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `source_twitter_id` bigint(20) NOT NULL, ...
2
votes
4answers
159 views

SELECT Statements only please

I have a user that wants to use SQL Server Management Studio (SSMS) to run SELECT statements. I don't want him to be able to modify data. I can't regulate his permissions through Windows ...
1
vote
3answers
136 views

Query missing one date; only happened today

This should be pretty reproducible I hope. I'm on Oracle 11g. This query, which I use as part of another query, is acting strangely: SELECT TRUNC(SYSDATE - ROWNUM) DATEITEM ...
2
votes
0answers
530 views

SQLite Performance Tuning

I have the following query, which fetches data from only one table. It is a query which is supposed to return data for an autocomplete function. Autocomplete data can be in text1 or text2. The ...
1
vote
1answer
54 views

Query from database

I have a table named mip. The table has primary key id, a foreign key product_id and a column usage_type. product_id is a primary key id to a table named product. It is one to many relationship from ...
0
votes
0answers
253 views

How do I get the date that each user last logged onto the server / database in SQL Server 2005

Currently, I have the following code that gets the DBNAME, USERNAME, ROLE_NAME for each user on the database. I need to get the last logged in date for each user to fill in the LASTLOGIN_DATE. ALTER ...
3
votes
2answers
1k views

Unable to disable SQL statement logging in PostgreSQL 9.1

I am running PostgreSQL 9.1 on Windows Server 2008 R2. I enabled SQL statement logging to the stderr log by modifying my postgresql.conf file, but now I can't seem to disable the logging without ...
3
votes
1answer
538 views

Oracle sequence generation performance during persists of large data sets

In the context of an Oracle sequence, when persisting > 200 million records, is there a performance hit on the database if the sequence cache is the default value of 10000? That is to say does ...
1
vote
1answer
1k views

Convert spatial points data to line data for use in Line Layer in SQL Server Reporting Services (SSRS)

I have a query that returns the fields Order, Lat, Long, SpatialData, <OtherStuff>. SpatialData is a point. I want to create a line layer that draws lines between my points based on the order ...
1
vote
1answer
448 views

The best way to log access to SSRS reports

We have a number of SSRS reports created using BIDS 2008 on SQL Server 2008 r2. The business wants us to log access to these reports. For example who and when run the Report A. What is the best way ...
1
vote
1answer
152 views

Does MySQL compress the stored data?

When I export a database in MySQL, it gives me a .sql file. Let's say this .sql file is 80 MB. Are they compressed in order to reduce disk space usage? Is that 80MB real physical-storage size?
3
votes
2answers
4k views

Parallel inserts cause deadlock on DB2

The scenario is the following: The application attempts to insert into the same table from two parallel threads making 4000 insertions in each thread (separate transaction per thread). It causes the ...
2
votes
1answer
95 views

What are the effects of GRANT DELETE?

What is the difference between: GRANT DELETE ON TABLE1 TO ROLE1 and GRANT DELETE TO ROLE1 One of our DBAs executed the second version by mistake. I want to be certain I understand all the ...
1
vote
1answer
502 views

Can I install sql server on Win XP machine with user profile on D drive?

Is it possible to install sql server on a windows xp machine where the user profiles are created on a non system root directory, that is, on D drive rather than C drive? I am trying to install SQL ...
0
votes
3answers
2k views

How to attach .mdf file to SQL Server 2005 without an .ldf file?

I want to attach a database to SQL Server 2005 but I have only its .mdf file How can I attach it?
3
votes
2answers
915 views

Deprecating SQL Server, need to redirect clients to new server

I am in the process of deprecating an old SQL Server server and replace it with a new server. My old SQL Server is a named instance called: SQL\Development My new SQL Server is a default instance ...
1
vote
2answers
3k views

Move postgresql database from one server to another

I have created a (spatial) database at my home which is several gigabytes and I want to move the whole database as it is from one computer my works computer. Nothing fansy, I will create a new ...
2
votes
1answer
1k views

SQL Query - Set Date Variable by Table/Column Reference

How do I set the @DATE variable by using a table/column reference? Right now I've set it manually as you can see below with the opening: SET @DATE = '2012-03-31 01:00:00'; The table from which I ...
-1
votes
2answers
222 views

Information sources for multiple hierachy trees in a single table

I need some quality sources - books, websites etc. - to educate myself about putting multiple hierarchy trees in a single table using SQL. I'm looking for some good theoretical and practical ...
6
votes
3answers
6k views

Restrict update on certain columns. Only allow stored procedure to update those columns

I have sensitive price columns that I would like to have updated only through a stored procedure. I would like all code or manual attempts to alter values in these price columns to fail if it is not ...
3
votes
3answers
6k views

Alternative query to this (avoid DISTINCT)

Note: I work with MSSQL 2008, but I guess it's valid for many others DB engines I have this table "Users": UserID User CountryID 1 user 1 1 2 user 2 2 3 user 3 3 4 user ...
1
vote
1answer
1k views

Production SQL Server High CPU for a Single Query

I have a single query which is consuming a larger amount of CPU than I would expect in SQL 2008. I am not able to determine why the CPU is spiking for this single query. I can trigger an ...
3
votes
1answer
116 views

Slow MySQL query, not sure why

I'm working with an intranet application for property tax collection, and I've hit a snag. The following view runs much slower than I'd expect: create or replace view propertytaxessub0 as select ...