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)

-4
votes
1answer
3k views

Can I create a view against a table on another instance? [closed]

I need to query a table from another SQL Server on a different server but same domain, but I am not sure how I will be able to do it. I tried the solution in this answer but it doesn't work for me as ...
3
votes
1answer
449 views

Limiting database security

A number of texts signify that the most important aspects offered by a DBMS are availability, integrity and secrecy. As part of a homework assignment I have been tasked with mentioning attacks which ...
3
votes
1answer
157 views

Custom sp_who/sp_whoUsers

I need to allow a client in a dev DW SQL 2K8R2 environment, to view and kill processes, but I do not want to grant VIEW SERVER STATE to this person (he's a former sql dba and is considered a potential ...
1
vote
2answers
521 views

Stored Procedure in MySQL

I am new to MySQL Stored Procedure, in my first attempt I got the following issues, Stored Procedure: Delimiter $$ create procedure accountstatus ( IN inmode varchar(27), IN ...
1
vote
2answers
139 views

Finding rows for a specified date range

I have a table which stores which teacher (teacherid) works for which group (groupid) of pupils starting from the date startdate: CREATE TABLE `pupilgroupteacher` ( `id` int(10) unsigned NOT NULL ...
0
votes
0answers
26 views

How to join multiple tables (SQL) to find the difference between an order and shipped quantities? [duplicate]

I have a collection of orders that were submitted to an internal ERP, which were processed and partially shipped. The table hierarchy is as follows: Order table contains OrderReference(PO), OrderID ...
2
votes
1answer
1k views

Does existing msrepl_tran_version column need to be removed when re-creating replication?

What is the process for removing a replication and then re-creating the replication. I know the process to set up replication. However, If i wanted to take a publisher database copy it and restore it ...
2
votes
3answers
773 views

SQL Server data extract with limited performance impact

Background: I have a SQL Server 2008 Enterprise Edition database containing three tables. The tables contain ~3 million, ~14 million, ~14.5 million rows respectively. Problem: I need to do a data ...
2
votes
2answers
128 views

How to monitor a single db of an instance in SQL Server

I am trying to program against a vendor supplied database, and would like to understand what SQL statements or procedures they are calling. Is there a way I can monitor a specific database? The ...
5
votes
2answers
3k views

The order of INNER JOIN's

I would like to know if there are any rules about the order of INNER JOIN's in T-SQL 2000. I had 62x the performance on my query when my INNER JOIN that act like a filter is placed at first instead ...
1
vote
1answer
3k views

Get top most parent by nth child id?

Now there is a question we commonly use this technique to maintain the parent child relation i.e we store all the entities in one tables with a parent_id column and all top most parents have 0 in the ...
1
vote
1answer
388 views

Column of generic/variable type?

In SQL, I would like to create a table which can contain generic data types. This types can change from every row. The solution I could come up to is: CREATE TABLE TagValue ( tag VARCHAR(64), ...
4
votes
2answers
3k views

COUNT of rows with parent id equal to the row we have with a parent id of 0 in one query

I'd like to do the following in one query using MySQL: grab a row that has a parent_id of 0 grab a count of all the rows that have a parent_id of the row that we grabbed which has a parent_id of 0 ...
0
votes
1answer
633 views

Export just rows modified in last month (date defined by user)

I'm asking if it's possible in MySQL to export just rows modified in a period of time for example in the past month, if it is possible, how?
2
votes
2answers
159 views

MySQL #1064 error on line 2 [closed]

I'm quite new on learning SQL and I seem to be running into an issue with the following code: CREATE TABLE `read` (`order` NOT NULL UNIQUE AUTO_INCREMENT, `title` VARCHAR(50) NOT NULL, `url` ...
-1
votes
1answer
60 views

Database update rather than cycle through? [closed]

I'm new when it comes to MySQLi and databases so I'm not sure how exactly to title this question. I have a PHP script setup to where it inserts data into the database. Pretty self explanatory. ...
1
vote
2answers
216 views

SQL Server 2005 onwards- Capturing Baseline

I want to design a process by which I can capture the baseline data of multiple SQL Server instances (2005 onwards) in a single database from where I can get all the info and alerts. As of now I ...
21
votes
2answers
4k views

Check existence with EXISTS outperform COUNT! … Not?

I've often read when one had to check existence of a row should always be done with EXISTS instead of with a COUNT. Yet in several recent scenarios I've measured a performance improvement when using ...
0
votes
2answers
386 views

How does Log shipping knows to keep track [duplicate]

I have set up log shipping between 2 SQL Servers (SQL Server 2008 and SQL Server 2012), At first i took a full backup of the first one and restored it on the other one and than i set up the log ...
3
votes
1answer
2k views

How does Log shipping knows to keep track

I have set up log shipping between 2 SQL Servers (SQL Server 2008 and SQL Server 2012). At first i took a full backup of the first one and restored it on the other one and than i set up the log ...
1
vote
1answer
1k views

Constraint based rules engine

I am evaluating software systems which configure products that tout constraint based versus rules based engines. Can someone explain (with maybe an example or two) to a non-expert what the difference ...
7
votes
1answer
164 views

IN and NOT IN for XML column

I have a table with a xml column. Xml is similar to <Root> <Row> <user>abc</user> <Rowid>1</Rowid> </Row> <Row> ...
4
votes
1answer
3k views

How do I get the aggregate of a window function in Postgres?

I have a table containing a two columns of permutations/combinations of integer arrays, and a third column containing a value, like so: CREATE TABLE foo ( perm integer[] NOT NULL, combo integer[] ...
2
votes
2answers
1k views

Problem with order by in MySQL subquery

I'm running a query that runs in about 2 seconds when the subquery does not include the order by date_sold clause. However, when I add the order by clause, the query runs forever. I'm confused, since ...
3
votes
1answer
160 views

Most efficient ordering post database design

I have posts table that is has post_order column. I store order of each post in it. when I change the order of a row from 25 to 15, I should update all the row from 15 to end. It's good for few rows, ...
-3
votes
1answer
987 views

How to merge two rows in a table? [closed]

I have a table called Person with columns Col1, Col2, Col3, etc. In Col1 I have two values: ABC and XYZ. What I want is to replicate all the values from the other columns (Co2, Col3, etc.) for the ...
4
votes
3answers
3k views

SQL Server 2008 - performing nightly full backups & transaction log shipping, but log file keeps growing

Rather perplexed with my SQL server Log file. With identical primary & secondary servers, the production server on live sends the log files to the secondary every 15 minutes. Also, every evening, ...
2
votes
2answers
266 views

How to join multiple tables (SQL) to find the difference between an order and shipped quantities?

I have a collection of orders that were submitted to an internal ERP, which were processed and partially shipped. The table hierarchy is as follows: Order table contains OrderReference(PO), OrderID ...
0
votes
1answer
368 views

Need to find the number of employee who are not in all department

i have a table T1 which has two columns empname , department every emp must be in 37 department , but there are some employee who are in less than 37 department . I need to find the names of emp who ...
0
votes
1answer
106 views

Foreign key in MySQL

I am learning about database, I need to know something about the foreign key in MySQL. Consider the following two tables. UserGroupType. UserGroup. UserGroupType: UserGroup: In this table ...
0
votes
1answer
92 views

How to optimize query?

I need to optimize the following query: SELECT DISTINCT column1, column2 FROM tbl_name WHERE column3 = 'x' AND TRIM(UPPER(column4)) = TRIM(UPPER('y')) AND TRIM(UPPER(column5)) = ...
2
votes
3answers
141 views

Performance difference between searching table with 350 columns and searching table with 25 columns

I am currently doing some hibernate performance test. My requirement is to search for data in a particular column of a table containing 8 million rows and 350 columns. Currently, I don't have the ...
1
vote
2answers
72 views

Practical way to temporarily shut down a database

What would be the most practical way to shut down a database to access for any user? I need to practically shut down a specific database on a SQL Server for test purposes, and would like to know the ...
1
vote
1answer
253 views

Polling for new records in a table

We have a table that is append+read only. We'd like to have multiple applications consume all new rows that show up in that database, in a cheap and easy way (without change tracking). The simple ...
1
vote
1answer
111 views

Unable to generate a MySQL query

I have a table in a MySQL database as below: ID Timestamp State 1 2013-07-10 09:00:00 Good 1 2013-07-10 09:10:00 Good 1 2013-07-10 09:20:00 Good 1 2013-07-10 09:30:00 Bad 1 ...
1
vote
1answer
335 views

Inserting filtered data from one table to another

I need to find the number of employees who are not in all departments. I have one more table T2 in which same department column is present. Now I want to insert only those values of department which ...
2
votes
1answer
444 views

Longest prefix search in Oracle

I have a list of phone number prefixes defined for large number of zones (in query defined by gvcode and cgi). I need to efficiently find a longest prefix that matches given number PHONE_NR. I use ...
-1
votes
1answer
579 views

dead lock when updating [closed]

Update Operation.TrTable Set RecordId = RecordTABLE.newRecordId From Operation.TrTable tr Inner Join ( SELECT r.Id AS newRecordId, r.KeyM AS MappingKey From ...
-1
votes
1answer
59 views

What could I possibly be doing wrong with this update statement

UPDATE pcdbak SET pcdbak.Title = pcd.Title FROM pcd, pcdbak WHERE pcdbak.eCommNum = pcd.eCommNum This was the error message: [Err] 1064 - You have an error in your ...
1
vote
1answer
50 views

Getting related data from an uncertain column

I am working on a friendship logic, the table friendship has this structure: `friendship_id` INT NOT NULL , `user1_id` INT NOT NULL , `user2_id` INT NOT NULL , `status` INT NULL , `created` ...
2
votes
2answers
9k views

Get username and/or IP address responsible for a query

I use the following query to find performance improvements in queries: SELECT TOP 20 SUBSTRING(qt.text, (qs.statement_start_offset/2)+1, ((CASE qs.statement_end_offset WHEN -1 THEN ...
9
votes
0answers
4k views

Fast SQL query with * but extremely slow with specific columns? [closed]

We have a query that we're running on SQL Server 2008 in the Management Studio. I can't give the exact query details, but let's say it's equivalent to this: SELECT * FROM MyView a (nolock) INNER ...
5
votes
1answer
542 views

How can a fill factor of 0 or 100 be the same?

As of my understanding, Fill factor of 80 implies that 20 percentage of each leaf-level page will be empty to enable future growth. I can't correlate how fill factor of 0 and 100 can be the same! Am I ...
2
votes
4answers
994 views

When do I use another type index than integer? (eg string) [integer vs string index]

I was reading about relational databases like sqlite and I always see the schema for user storage like: UserID (index) | Username | Password but wouldn't it be actually much faster to use Username ...
3
votes
1answer
396 views

Cumulative Game Score SQL

I have developed a game recently and the database is running on MSSQL. Here is my database structure Table : Player PlayerID uniqueIdentifier (PK) PlayerName nvarchar Table : GameResult ID ...
8
votes
1answer
981 views

IO_STALL question and understanding

I am collecting IO_STALLS from sys.dm_io_virtual_file_stats every 5minutes and then doing a delta to see which files are being affected most by IO. In one 5min period I get a delta of 5826331 ms ...
13
votes
7answers
25k views

Get the rank of a user in a score table

I have a very simple MySQL table where I save highscores. It looks like that: Id Name Score So far so good. The question is: How do I get what's a users rank? For example, I have a users ...
1
vote
2answers
153 views

Most efficient way to perform table operations (spec. drop) on tables having table names that match a certain criteria

I am performing a schema dump of certain tables. This accompanied by dropping the tables that will be dumped. For example I need to drop all tables that start with, let's say, "SRC_". You guys think ...
-5
votes
2answers
194 views

Inserting images in database [closed]

How can the images be inserted in a table? Var binary is not working in structured query language command prompt,what can be the syntax?
0
votes
1answer
356 views

RTF to Plain-Text? [closed]

Did you ever get the library from this post? We have a need to convert whole, large, whole tables worth of RTF information into something usable and would rather not reinvent if possible. Converting ...