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
126 views

put number inside database sqle server in arabic format I do not want it in english format I need it in arabic [closed]

I do not want the number in English format I need it in Arabic I am sorry my problem I inserted number in my table in English(e.g 5),but I want to replace it in Arabic format. because I need it in ...
1
vote
0answers
810 views

Microsoft SQL server 2012 error 18456 with domain credentials [closed]

I have a SQL server 2012 setup to use windows authentication. Remotely I can connect to "Server A" no problem with domain credentials but when I try to locally connect to "Server A" with SSMS it ...
0
votes
1answer
905 views

select row data as column list

In my database I have a set of custom field values that can be setup by the customer. They can create labels for these fields and then assign values which are linked back to particular tables in the ...
2
votes
0answers
1k views

Mysql slow writes

i have a strange problem with mysql. My selects goes fast. My insert/create/delete/drop/update go very slow. I have done some tests on 2 machines. My old machine and my new machine. Old is worst ...
0
votes
0answers
267 views

Getting Request Timeout from Store Procedure?

Only sometimes, I get Request Time-out(means my SP is not responding within a specfied time-period which is 90 seconds). Here is my SP. ALTER PROCEDURE [dbo].[Insertorupdatedevicecatalog] ...
0
votes
0answers
1k views

How to concatenate multi row sql output

Version Information: Oracle Database 11g Release 11.1.0.7.0 - 64bit Production HP Server Automation v9.14 I am creating a report of all my HP-SA managed servers. The report includes data from ...
1
vote
1answer
425 views

MySQL query optimization with aggregate ORDER BY

I have an analytics table that stores metrics aggregated the day level. I need to ask questions such as "For a given date range and client, what are the most popular items." The schema is as follows: ...
2
votes
1answer
366 views

Getting the most out of SQL Server with a million rows a day [closed]

I have a windows service that is inserting 1000 rows at 1 minute intervals to a SQL Server 2008 Standard database table that looks like: id, datetime, key_id, value key_id is a foreign key to ...
0
votes
0answers
256 views

Problem with PIVOT [closed]

I am facing a small issue while using PIVOT table. My problem is as following. I have a single table with the procedures id and their steps and i want all the steps needs to be displayed in 5 column ...
2
votes
3answers
12k views

Find rows where any column matches a search pattern

I have a table "Test" with 15 different columns of different data types. I'm looking for rows having characters like "ABC". But "ABC" can be present in any column and I want to find whole records ...
1
vote
0answers
4k views

How to speed up query on table with millions of rows

The Issue: I'm working on a big table that consists about 37mln rows. Data include measurements of many devices made in certain time e.g. '2013-09-24 10:45:50'. Each day all of those devices are ...
3
votes
2answers
362 views

Is it good practice to check for existence of records before deleting them

I've came across the following SQL/PLSQL while investigating a stored procedure written by someone else: 1. V_COUNT NUMBER(5,0); ......... 2. SELECT COUNT(*) INTO V_COUNT FROM TABLE1 WHERE ...
1
vote
1answer
83 views

Slave as a master in PostgreSQL [closed]

I have set up a hot standby in PostgreSQL 9.0 on Windows. I want that, at the time of fail-over, the slave should take over the role of master and start performing operations (both read and write) ...
1
vote
2answers
2k views

mysql… compare and match items in same column

I have a column full of server names. For example; LouServer01 VgsServer01 LouServer02 VgsServer02 I need/want to be able to create a query that can match those two names based on everything after ...
0
votes
1answer
129 views

Unify case when changing fields values

I have the following code: $sql= 'select *,'. 'case when fisicas_cpf is not null then null else razao_social end as razao_social,'. 'case when fisicas_cpf is not null then null else ...
0
votes
3answers
3k views

COALESCE returning NULL when there are no records

When running the following query on a device_id that has no entries in the inv_zfs_replication table the result is a NULL value. How can I make the 2nd sub-query return a zero if there aren't any ...
7
votes
2answers
7k views

Why does MySQL allow HAVING to use SELECT aliases?

In SQL, as far as I know, the logical query processing order, which is the conceptual interpretation order, starts with FROM in the following way: FROM WHERE GROUP BY HAVING SELECT ORDER BY ...
1
vote
1answer
297 views

Paging and grouping using CTE?

Given the following code, from the answer to this question, how can I adapt it for paging? I've read that Common Table Expression is a good way to do paging, but since I implemented CTE to solve a ...
7
votes
4answers
25k views

Execute a script with SQLPlus containing blanks, semi-colons, and forward slashes

Occasionally I will get a script that will run fine in SQL Developer or Toad, but requires modification in order to be run successfully from SQL*Plus. Here is a worst case example containing multiple ...
4
votes
3answers
52k views

Oracle SQL - CASE in a WHERE clause

Is it possible to somehow do this? WITH T1 AS ( SELECT 1 AS SEQ, 'NOTHING 1' AS SOME_TYPE FROM DUAL UNION ALL SELECT 2 AS SEQ, 'NOTHING 2' AS SOME_TYPE FROM DUAL UNION ALL SELECT 3 AS SEQ, ...
0
votes
1answer
2k views

Converting .TPS (TopSpeed) to SQL

I have an older application that uses TopSpeed as the database engine. I want to use some of the data contained in these tables in another application that uses SQL. To accomplish this, I purchased ...
0
votes
2answers
529 views

What am I doing wrong in mysql database?

I'm creating a trigger that deletes rows from a table when they are inserted. However, when the trigger executes I get the following message: MYSQL ERROR: Can't update table 'player_viplist' in ...
0
votes
1answer
127 views

Multiple filters with joins

I just read this qestion: SQL Multiple Filter - Optimal Way I tried this with Northwind. I filter like this: declare @supplier int = 1 declare @category int = 1 select * from products p WHERE ...
6
votes
5answers
82k views

How to show the column names of a table with a simple sql query?

The case is simple: You have an mysql database where you have only sql query interface and you want to know the database structure with queries. You can list tables with show tables; command but how ...
0
votes
1answer
103 views

How to reduce table duplication, while ensuring integrity of the database?

For example, in my app I have some class called Contact: case class Contact(name: String, email: String, phone: String) And several other classes have one-to-many relation to that contact (for ...
0
votes
0answers
805 views

FOR loop oracle query with calulation

I have a list of distinct areas, and would like to track statistics for those districts in a SQL statement. I currently have a setup that runs some summary information, but it doesn't include the ...
2
votes
2answers
289 views

Dynamic Joining Across Databases

I have a multi-database architecture with a single database for each client and a separate database to handle system-wide data. In this separate database, I have an 'Updates' table where a row is ...
1
vote
3answers
4k views

Simple select is taking too long

I am facing an issue with the performance. The selection of data from table is taking more than 20 sec to retrieve close to 300k records. Created a clustered index on col1 and col2 but no improvement. ...
1
vote
0answers
373 views

How to store object with property of generic type in DB

In my business domain there exists an entity parameter. Beside other properties which are identical for each parameter, they have values. These values can be of different data types. There might be ...
3
votes
1answer
3k views

Concatenate one-to-many field in single result?

Say I have the following query: SELECT * FROM AppDetails, AppTags WHERE AppDetails.AppID = '1' AND AppDetails.AppID = AppTags.AppID Which gives the following results: AppID AppName ...
3
votes
2answers
8k views

Restore of database failed [duplicate]

I wanna restore my database and i use sql server 2012 express edition but when i restore my backup file in sql server management studio, i take this error: System.Data.SqlClient.SqlError: There is ...
0
votes
1answer
164 views

retrieve data based on a condition

I have 2 tables, TA and TB: TA -------- id name 1 a 2 b 3 c 4 d 5 e 6 f TB -------- id p_id name 1 1 a 2 1 b 3 1 c 4 2 a 5 2 b 6 2 d I need : if ...
0
votes
1answer
815 views

what server role that needs to be configured for the user to enable sql server agent

I'm on SQL SERVER 2008, I want to enable the SQL Agent for a particular user, who has only read access to the database. I don't want to give sysadmin role? Is there any way, I can do this?
1
vote
0answers
26 views

Optionally free-form reference

I've seen a few instances of entities which have a field which can be either a reference to another entity or free text. You typically represent this in the UI by having a dropdown widget which can ...
0
votes
1answer
227 views

how auto_increment work in mysql

im confused here , i create a table and have 2 columns id and name. Now id is primary key , not null and auto increment. Suppose i fire: insert into table (name) values('test'); this will give me: ...
4
votes
1answer
6k views

ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDOTBS1'

I am getting this error as a result of performing Insert and Select operation which involves calling of number of pl/sql procedures and functions. I am not getting exact reason. I tried optimizing ...
1
vote
1answer
117 views

How to DRY record metadata in SQL Server

There is a database that has been given to me, and all tables contain these columns: CreatorUserId CreatorUsername CreationDate ModifierUserId ModifierUsername ModificationDate However, it seems ...
1
vote
1answer
104 views

MySQL SUM related to parent query

I'm trying to put together a query to aggregate some information into a view, and am having trouble working out how to get that data I need from a couple of different tables. I'll start by describing ...
0
votes
2answers
781 views

Lock Pages in Memory keep SQL database engine stuck at allocating 60MB ram?

I'm using Window Server 2003 Enterprise, Microsoft SQL Server 2005 Standard Edition. The problem is the SQL Server memory gets stuck at allocating 1.7GB RAM max even though I have 11GB of RAM left. ...
0
votes
2answers
135 views

Enabling Edition Based Redefinition failed with ora-33819. Could I query why?

I want to enable Edition Based Redefinition for a user. Executing this command gives an ORA-33819 exception: ALTER USER user ENABLE EDITIONS; I know there's an option to enable it with the ...
0
votes
1answer
610 views

How to avoid duplicate entries with SELECT statement?

+----+----------------------+---------+---------+---------------------+-------+ | id | translation | id_word | id_user | added | tuser | ...
6
votes
1answer
192 views

Database restructure - beneficial?

I have a table for email messages. Then, I have a table that has the message parts. The Parts table contains a field_id, message_id, and data At the time I used Parts to name the table and ...
0
votes
1answer
82 views

Multiple values for unique id? [closed]

I have two tables: customer and boxes in one-to-many relationship. The structure of the tables is in addition : Customer table : id#| name | date_purchased | address | 1 John ...
1
vote
1answer
92 views

Count duplicate versions of databases (SQL Server 2008 R2)

I wish to pull statistics on the number of duplicate database versions we have running in our environment - most databases run with version control in the database name, so I built this query: SELECT ...
3
votes
0answers
535 views

Getting distinct list of records based on the MAX of a column

I have a status table (tblTestActionStatus) which has three columns ID_TestAction: references some test action ID_Status: a look up table reference for the variety of possible statuses for the ...
0
votes
0answers
42 views

How to optimize this query more?

First at all I am nood into SQL thing, Now I am working on a class project where I have some tables like Table user user_id | username | name 1 | nihan | Nihan Dip 2 | dip ...
3
votes
2answers
2k views

Row count from a certain table in multiple databases

I need to know the row count of a certain table that exists (or don't) in multiple databases. Here's what I came with: DECLARE @NomeBase as char(60) declare @base as char(100) declare @select as ...
-3
votes
1answer
653 views

How to retrieve a query from 3000 tables in SQL? [closed]

I have plan to create 3000 tables for my database. But I am afraid how will I retrieve some data from those many tables. Eg: Select * from table1, table2, table3.... table3000 where ...
2
votes
1answer
345 views

Why would a query in code be slower than a query in a SQL tool

When we face performance issues with out application, one of the first things we do is try to isolate if the problem is the code, the queries or the database itself. The most frustrating part of this ...
-3
votes
1answer
95 views

Sproc - Adding columns with matching ID column [closed]

I currently have a sproc that is used for reporting on a table similar to the one below: ID Weight QTY OtherData 1 20 12 1234 1 44 4 1234 ...