dialog
listlengths
4
30
title
stringlengths
15
150
category
stringclasses
14 values
dialog_time
stringdate
2016-01-21 01:59:30
2018-07-01 01:34:46
[ { "message": "I have the following <code>PIVOTING</code> query:<pre><code>SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTEDSET NOCOUNT ONSET DEADLOCK_PRIORITY LOWSELECT * FROM (select jsc.applicationid ,[the date of change]=MIN(jsc.changedate) --,jsc.[oldStatus] ,jsc.[new...
Calculate and show DATETIME difference on PIVOTING query
dba
2017-06-22T11:01:37.287
[ { "message": "I apologize if this is somewhat of a rookie question.After looking online I found some articles that explain how to find the worker time per query using sys.dm_exec_query_stats. e.g.<pre><code>SELECT TOP(10)creation_time, last_execution_time, (total_worker_time+0.0)/1000 AS total_worker_time, (tot...
How can I find out what my SqlServer 2005 CPU is mostly working on?
dba
2017-06-22T15:23:31.717
[ { "message": "I would like to know if it makes sense to create an index combining two functions while using Full Text Search: <code>lower(name)</code> and <code>f_unaccent(name)</code> Where <code>f_unaccent</code> is just my wrapper to make unaccent function immutable.I do have an index working on: <code>f_una...
Creating a case-insensitive and accent/diacritics insensitive search on a field
dba
2017-06-22T15:45:10.197
[ { "message": "One I selected the query from my <code>product</code> table with an additional Row_Number() column (Num), I'm getting the answer like below (I limited only 20 rows to retrieve).Query<pre><code>SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY ProductCode) AS Num, ProductName FROM ...
How to Skip rows in a SQL Server Query?
dba
2017-06-22T21:43:31.403
[ { "message": "I have a replication enviroment and is working fine, but today my disk going full.I check and see that the <code>mysql-bin.xxx</code> files are growing very very fast (I know they contain all changes in the database(s), so naturally they will grow, but today it is not normal the way that they are ...
The mysql-bin.xxxx files are growing very fast
dba
2017-06-23T19:58:48.160
[ { "message": "I have a postgres 9.6 table called <code>selected_media</code>, with a column called <code>_type</code> that is set to either <code>book</code> or <code>movie</code>.I want to select the <code>COUNT</code> of each type, in 1 single row, like this:<code>25 | 715</code>To do this, I have this query:...
PG: How to show total count for this query if result is 0
dba
2017-06-24T17:02:17.633
[ { "message": "I need to remove roles and users from postgres AWS RDS.Can you please suggest on this issue, please share the queries for this.", "role": "user" }, { "message": "If the account is authorised in postgres its just the same command as it would be in a normal postgres server:<code>dropuser...
Remove roles and users from postgres AWS RDS
dba
2017-06-26T09:12:52.313
[ { "message": "I'd like to add a check constraint to a table in azure data warehouse. I have the below script:<pre><code>alter table [FactTbl_Test] add constraint Ck_Test_id check ([Test_Id] != 'Unknown')</code></pre>This causes the below error:<blockquote> Parse error at line: 2, column: 74: Incorrect syntax n...
How to add a check constraint in sql azure data warehouse?
dba
2017-06-26T11:23:17.943
[ { "message": "after much researching and experimenting, I figured I would make an attempt to get some expert advice.I am maintaining a stored procedure that is executed as a job. It creates a table with data nicely defined. It then uses an OpenQuery to collect some data and insert it into the table. Example:<pr...
Most efficient way to insert data to MS SQL table from OpenQuery on DB2 linked server?
dba
2017-06-26T20:45:08.933
[ { "message": "I am tasked with looking at if a database in SQL Server 2014 needs to be defragmented. I ran DBCC SHOWCONTIG but am having trouble interpreting the results.<pre><code>use databasename;GO DBCC SHOWCONTIG ('Table'); GO </code></pre>The results are:<pre><code>DBCC SHOWCONTIG scanning 'Table' tabl...
Figuring out if SQL Server database needs to be defragmented
dba
2017-06-26T21:08:51.707
[ { "message": "I am Trying to create a view based on a business calendar table called Business Payment Calendar view with two new calculated columns:Payment Warning Date (<code>Payment_Warning_Date</code>)Payment Due Date (<code>Payment_Due_Date</code>)And, also the non-calculated <code>Transaction_Date</code>Th...
Using Oracle XE, how do I create a CASE statement To return a specific date
dba
2017-06-27T01:25:35.467
[ { "message": "I am a little confused about the indexing I am going to do.First, I am using a 4-column index, like this:Index Name - advanced_queryColumns will be used in the index - title, category 1, category 2, category 3The Indexing Code<pre><code>ALTER TABLE table_name ADD INDEX advanced_query (`title`, `ca...
Will this indexing work as I think it will?
dba
2017-06-27T05:29:46.593
[ { "message": "I'm experimenting with creating a 2-node SQL Server Availability Group following Guy Glantser's excellent guide at <a href=\"http://www.madeiradata.com/availability-group-sql-server-2016/\" rel=\"nofollow noreferrer\">MadeiraData where he describes a configuration with no AD domain or internal DNS...
SQL Server AG Listener issues in an AWS VPC
dba
2017-06-27T12:47:31.593
[ { "message": "I have a table with a column with the account IDs and I need to create a hierarchy scheme. So I created a column to add the parent account IDs, but I do not know how to update dynamically.I updated some records manually to find out how it would look, how could I make a script to update the other a...
Update parent id Hierarchy - SQL Server
dba
2017-06-28T12:40:39.773
[ { "message": "We have a rather complex database setup which involves 500 schemas. Most of these schemas contain a certain table. This table contains a certain number of rows and those rows contain a size field.I need to iterate the schemas, detect those schemas that contain the relevant table and count the numb...
Count number of rows and sum up a field of all tables in all relevant schemas with a readonly connection
dba
2017-06-28T15:26:33.903
[ { "message": "I have a database with sale data for the past 5 years, 2012 - current. I am in need of showing a breakdown by employeeID and the monthly sale amount. I know this syntax will work, but it is going to be quite cumbersome to add a new case statement every time we roll into a new month. Is there a ...
Show Monthly Revenue By EmployeeID
dba
2017-06-28T15:48:48.567
[ { "message": "I have the following index I'm trying to modify by declaring the <code>poLineNumberInteger</code> key as numeric/integer instead of text. This is valid syntax:<pre><code>CREATE INDEX ubdrecord_jsonb_extract_path_text_idx ON public.ubdrecord USING btree (jsonb_extract_path_text(metadata, VARIADI...
Proper way to create an integer jsonb nested key index
dba
2017-06-28T17:43:38.333
[ { "message": "I borrowed some code on how to compact and uncompact a string of diagnosis codes in order to build a bridge table for my data warehouse. It works well. However, I just do not understand how it is doing the uncompacting. <a href=\"http://sqlfiddle.com/#!6/6f272/4/0\" rel=\"noreferrer\">Here Is the ...
How does this derived table with cross apply work?
dba
2017-06-28T18:44:39.273
[ { "message": "I borrowed some code on how to compact and uncompact a string of diagnosis codes in order to build a bridge table for my data warehouse. It works well. However, I just do not understand how it is doing the uncompacting. <a href=\"http://sqlfiddle.com/#!6/6f272/4/0\" rel=\"noreferrer\">Here Is the ...
How does this derived table with cross apply work?
dba
2017-06-28T18:44:39.273
[ { "message": "I am a SQL Developer (not DBA or Architect) for a small (~50 employees) SaaS company. I am tasked with figuring out how to: Offload operational reporting from our 100+ OLTP databasesAllow those reports to run against data from multiple client databasesPosition our company to provide more analytic...
Looking for advice on how to integrate data from 100+ client DB's into a centralized reporting database
dba
2017-06-28T21:20:59.707
[ { "message": "I have a sequence and trigger that provide auto-incrementing IDs to a <code>PROJECT_ID</code> column:<pre><code>PROJECTS+------------+-----+| PROJECT_ID | ... |+------------+-----+| LC000001 | || LC000002 | || LC000003 | || LC000004 | || LC000005 | |+------------+----...
Auto-incremented ID with sequence and trigger: How to handle manual overrides (causing non-unique error)
dba
2017-06-28T21:37:54.923
[ { "message": "I have this pretty straightforward SQL query<pre><code>SELECT count(date_mdy) AS unique_date_count, county, date_sFROM ( SELECT date_mdy, county, date_s FROM air_quality2 GROUP BY county, date_s ,date_mdy ORDER BY county, date_s) AS t1 GROUP BY county, date_s ORDER BY date_s;</code><...
postgres row to column
dba
2017-06-29T13:59:26.173
[ { "message": "I have two tables users and login_track. Each user may or may not have login records in login_track table. I want to retrieve recent 2 login dates for each user.Table structures as below:<br>users: <pre><code>user_id name 1 John 2 Mike 3 Anderson .....</code></pre>log...
Mysql Select recent 2 records for each group[user]
dba
2017-06-30T08:18:31.353
[ { "message": "I have a backend that log event to Redshift, for each event it generates a unique id. The id is a sequential number.I have something like (<code>events</code> table):<pre><code>+-------------------------+------+| created_at | id |+-------------------------+------+| 2017-06-30 09:20:...
Validate id sequence consistency in records in Redshift
dba
2017-06-30T15:04:32.467
[ { "message": "I want to create database for smartphone and its features with feature category <pre><code> Feature Category------------------------|id name------------------------|1 Processor|2 Memory|3 Display|_______________________Features------------------------------------------------|...
Database design for smartphone product and its features
dba
2017-07-02T08:12:36.497
[ { "message": "Suppose We have a replica set with 1 primary and 2 secondaries. During write operation on Primary, will write commit happen at once upon finishing write operation on primary and before spreading changes to secondaries? Or it will happen once all changes will be apllied on secondaries?", "role"...
Write commit in replica set MongoDB
dba
2017-07-02T11:32:01.837
[ { "message": "Newbie here. I've got an SQL Server database, and I want to give someone permission to do almost anything to it except access a particular schema or mess with my user and my user rights. I see how to protect my schema, but how do I protect my user's rights?Thanks", "role": "user" }, { ...
Need help with SQL Server permissions
dba
2017-07-02T21:05:17.783
[ { "message": "I'm getting into the dba world for SQL Server via \"trial by fire\", and I have a IO question.I have a SQL Server 2016 engine built upon Windows Server 2012. This setup includes:128Gb Ram6Gb/s Megaid SAS controller<a href=\"https://i.stack.imgur.com/KkQ9O.png\" rel=\"nofollow noreferrer\">4 x 600...
How to understand I/O bottleneck for SQL Server
dba
2017-07-03T13:24:15.360
[ { "message": "I have PostgreSQL 9.2 database and a table:<pre><code>id integer,allowed_types character varying(255)`</code></pre>Sample data as below:<pre><code>id allowed_types1 3,4,5,13,14</code></pre>How I can remove 4 and 5 from <code>allowed_types</code> which is a comma separated varchar list? After re...
How to remove an element from a col with a CSV of ints in PostgreSQL 9.2?
dba
2017-07-04T13:48:34.283
[ { "message": "When I run <pre><code>user-pc&gt; mysql</code></pre>It said <pre><code>ERROR 1045 (28000): Access denied for user 'Amir'@'localhost' (using password: NO)</code></pre>I can login with following command:<pre><code>user-pc&gt; mysql -u root -p</code></pre>So I try to find solution for this problem an...
ERROR 1045 (28000): Access denied for user 'User'@'localhost' (using password: NO)
dba
2017-07-04T16:49:51.063
[ { "message": "If I want to <code>INSERT</code> a row only if the primary key doesn't yet exist, is it more efficient/simpler to execute <code>INSERT</code> directly and ignore the error in the case of duplication, or should i always run <code>SELECT</code> to check if it already exists first?", "role": "use...
Always check with SELECT before INSERT?
dba
2017-07-05T07:35:09.483
[ { "message": "My colleague having DBA ROLE has created a user for me with the following role. <code>CONNECT</code>,<code>DBA</code>,<code>RESOURCE</code> from his own user.Then I login and check the detail by using the below query.<pre><code>select * from DBA_ROLE_PRIVS where grantee = 'MURAHMAN';</code></pre>I...
DBA privileges information
dba
2017-07-06T07:44:37.123
[ { "message": "I have a two node sql server 2008 r2 cluster that we just did an OS upgrade from windows 2008 r2 to windows 2012 r2, the OS upgrade was done in place so the SQL Server Installation stayed in tack. The cluster role won't come back online saying it's couldn't find any IP address that this instance ...
SQL Server FCI won't start after OS Upgrade
dba
2017-07-06T22:25:30.550
[ { "message": "I am having a real hard time trying to convert a TSQL statement (which be a store procedure) into a Dynamic SQL. Basically I must be able to pass the schema name as a parameter.Here is my code:<pre><code>DECLARE @query AS varchar(max)DECLARE @schemaName AS varchar(5) = 'wl03' -- To be used later a...
making a TSQL statement that has variables to be dynamic
dba
2017-07-06T22:39:45.493
[ { "message": "I have this table that is created every month. ex. <code>model201707</code> ('model' = fixed; '201707' = year &amp; month based on the current date):<pre><code>| COLUMN_NAME | TYPE ||---------------|-------------|| serial | varchar || lot | varchar || model ...
Execute dynamic INSERT ON CONFLICT DO UPDATE in plpgsql function
dba
2017-07-07T08:06:06.203
[ { "message": "So the title is not really clear, but I could not think how to put it into shorter words better. My problem is:I have a database, which I use for web-scraping, with different articles and their prices. The prices may change each month. To be able to have a history, I created two tables: <code>item...
Items from last month AND if not possible, items from this month
dba
2017-07-07T08:55:57.657
[ { "message": "I am creating MongoDB replication on local server by first manually creating three different databases folders with names like <code>MongoDB</code>, <code>MongoDB1</code> and <code>MongoDB2</code>. Each one of them have <code>data</code>, <code>bin</code> and <code>log</code> sub folders and an in...
creating replica set between three similar mongo databases on my local
dba
2017-07-07T11:40:03.780
[ { "message": "I have a server running Server 2012 R2 with SQL Server 2012 installed. The SQL Server Agent works fine if it is running under Local System. I changed the SQL Agent service account to a domain account and the service will not start. Checking the event viewer the only error message available is the ...
SQL Server Agent - Service Failed to Start (Access is Denied)
dba
2017-07-07T14:31:49.607
[ { "message": "I have a structure similar to this one:<pre><code>CREATE TABLE `author` ( `id` int(11) unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;CREATE TABLE `book` ( `id` int(11) unsigned NOT NULL AU...
Optimize a query with two range conditions
dba
2017-07-07T19:05:01.947
[ { "message": "I manage Oracle databases that are backed up using RMAN. How can I find gaps in the backed-up archivelogs?I.e., I want to detect when something like this happens:Take full backup with archivelogsBack up morning archivelogs and delete inputBack up evening archivelogs and delete inputSomeone permane...
How to find archivelog gaps in the backups
dba
2017-07-07T19:20:34.683
[ { "message": "In question: <a href=\"https://dba.stackexchange.com/questions/178299/optimize-a-query-with-two-range-conditions#178299\">Optimize a query with two range conditionsthe OP wanted to know if there were a way to optimize his query. In an answer given the query were rewritten as a <code>LEFT JOIN</cod...
What strategy does MySQL optimizer use when choosing between two indexes?
dba
2017-07-07T21:08:50.420
[ { "message": "I am trying to install PostgreSQL 10 beta from source code by following their documentation. Is it normal that make and make install take more than 12 hours to complete? Would using extra CPU cores and memory speed things up? Is there a binary available for Debian 8?Thank you!", "role": "user"...
Is it normal to take days to compile PostgreSQL from source code?
dba
2017-07-08T10:53:06.753
[ { "message": "<a href=\"https://i.stack.imgur.com/jcN1f.png\" rel=\"nofollow noreferrer\">As you can see here, in <code>OrderInfo</code> and <code>OrderNumber</code>, I have a relationship set. But I'm not sure what kind. I was hoping to set a relationship so if I deleted an <code>OrderNumber</code>, it would c...
Is there anything wrong with linking two identical primary keys in two different tables?
dba
2017-07-08T13:19:42.807
[ { "message": "<a href=\"https://i.stack.imgur.com/jcN1f.png\" rel=\"nofollow noreferrer\">As you can see here, in <code>OrderInfo</code> and <code>OrderNumber</code>, I have a relationship set. But I'm not sure what kind. I was hoping to set a relationship so if I deleted an <code>OrderNumber</code>, it would c...
Is there anything wrong with linking two identical primary keys in two different tables?
dba
2017-07-08T13:19:42.807
[ { "message": "Currently we use terminalservers to enable remote users to work with a central LOB-application. The terminalserver is on the same LAN as the <code>MS SQL-server</code>. Now my question is: what is the preferred way to replicate/mirror the database to the remote sites, so users don't need a termina...
Best practice bring MS SQL database to remote sites
dba
2017-07-08T18:50:30.050
[ { "message": "I've got two tables that I need a count on both of them.<pre><code>table1: idtable2: cid (table1.id = table2.cid) -- Join can be done by this.</code></pre>I already got two queries that I'm using, and wanna put them in one single query.Query related to <code>table1</code>:<pre><code>WITH c_status ...
Count 2 tables same query - PG 9.3
dba
2017-07-09T21:51:38.940
[ { "message": "I'm attempting to sort a result from a table that is multilingual. I would like to have the sorting algorithm come from a function but then it adds a 8% hit to the performance, at least. So, I'm not quite sure how to go about it. So, for the sorting I'm using this <a href=\"https://social.technet....
Sort Code Reuse for Multilingual Database
dba
2017-07-10T15:51:53.290
[ { "message": "I'm using a MySQL database to store logs from multiple servers. The database's growth on average is 50 GB per day. Its total size is now 1.7 TB.It has <code>ID</code> and <code>datetime</code> columns.I want to move data older than one week to another database on the same server.What are the steps...
Best Practice to Archive Old Data in MySQL
dba
2017-07-10T15:57:05.030
[ { "message": "I'm testing running monbodb on the kubernetes platform where I can limit the resources used by the running container.Say I set the memory limit to 256Mb. The problem is that for example while making backup memory consumption increases to the limit and container gets restarted by kubernetes.So the ...
mongodb limit server memory consumption
dba
2017-07-10T17:10:19.917
[ { "message": "I have a very large dump data(18GB) need to restore. I tried to use <code>mongorestore</code> to restore the data to a replica set. But the restore process canceled because of <code>error restoring from orders.bson: insertion error: not master</code>. I think this is because the master get changed...
How to handle master changed during mongorestore?
dba
2017-07-11T04:06:17.033
[ { "message": "I basically need a simple index creation script in a stored procedure as part of my database project.If the index in question already exists, I want to recreate it, to ensure that no other process has changed the index in question.I want to use <code>CREATE INDEX</code> with the <code>WITH (DROP_E...
Howto create an index without redundant code?
dba
2017-07-11T15:45:57.547
[ { "message": "Schema:<pre><code> CREATE TABLE \"applications\" ( \"id\" SERIAL NOT NULL PRIMARY KEY, \"country\" VARCHAR(2) NOT NULL, \"created\" TIMESTAMP WITH TIME ZONE NOT NULL, \"is_preliminary\" BOOLEAN NOT NULL, \"first_name\...
How to avoid a subquery in FILTER clause?
dba
2017-07-12T08:05:45.980
[ { "message": "I need an alternative to cursor/while loop for below query:We have a table as given in below screen shot containing the following columns: <code>ID</code>, <code>Module</code>, <code>Query</code>. The table contains nearly 100,000 records. Currently we are using cursor and a while loop to insert...
Retrieve value of select query in a table column
dba
2017-07-12T10:02:06.350
[ { "message": "So, I'm not a database expert (or really have much experience at all other than my college classes) and I need someone to point me in the right direction on how to design this problem. To be very clear, I'm out of school and I have my degree. This is NOT a homework problem.I work as a software eng...
What is the proper way to design this database?
dba
2017-07-12T21:19:49.387
[ { "message": "I have a database db on mongodb server <code>s0</code> with collection <code>coll</code> which is not sharded. To shard this collection I set up a sharded cluster and add <code>s0</code> to replica set <code>rs0</code>. Now I want to add the sharded cluster to this replica set <code>rs0</code> so ...
Add mongodb cluster to a replica set
dba
2017-07-13T07:34:01.583
[ { "message": "So my first query is this one:<pre><code>SELECT * FROM information_schema.columns WHERE table_name='logsys' and column_name in('CD_LOG','NM_USUARIO','DT_ACAO','DS_HISTORICO','NOME_MAQUINA','USUARIO_MAQUINA','DATA_REFERENCIA','ID_SISTEMA','VERSAO','LOCAL','ACAO','ID_LOG')</code></pre>Then to run it...
Select only databases with a certain table name and specific columns
dba
2017-07-13T12:49:17.487
[ { "message": "I created some columns in our production database but now I need to drop one. However this seems impossible and I do not know why. I dropped the column in our development database just fine. I created a table in production and dropped that. But when I try to remove this one column I get the er...
What causes "lock request time out period exceeded" when droping a column?
dba
2017-07-14T14:46:30.667
[ { "message": "We are doing sharding process for 6 servers which includes 1 master process, 2 config process, 6 sharding processes.<br>We enabled the sharding by doing <code>sh.enableSharding(database_name)</code> and <code>sh.shardCollection('mydb.collection_name', {_id: hashed})</code> It worked.<br>Now, if i ...
How to enable sharding for all databases/collections by default
dba
2017-07-18T12:45:11.957
[ { "message": "First off, yes, shrink is bad. Don't use it, ever. I understand. Unfortunately, it's kind of SOP and I'm not in a position to argue since it's usually a stopgap until we can get a maintenance window to allocate more space and rebuild/reorganize indexes.We recently had an issue where we were switch...
Determining what objects SHRINKDATABASE will free space from
dba
2017-07-18T14:19:37.660
[ { "message": "On CentOS 7.MongoDB version: 3.2.15There are two nodes:node1node2node1/etc/hosts<pre><code>127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 node1::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.0.100 node1192.168.0.101...
Can't add another node from primary node with MongoDB replication set
dba
2017-07-19T05:43:57.457
[ { "message": "Recently our SQL Server Log drive which has all T-Log files starting growing rapidly.ConsiderationsWe expanded drive space to 100 GB.It is AOAG environment, SQL Server 2014.We have regular backup of T-Log every 15 minutes (but no log drive space is freed up and log drive is increasing more and mor...
Shrinking T-Log file every weekend basis
dba
2017-07-19T09:23:36.520
[ { "message": "I'm relatively new to SQL Server, and having a problem with an expanding tempdb database. As such, I'm starting to look just more generally into how database files work.Looking at this query:<pre><code>USE master;SELECT *FROM sys.master_files mf</code></pre>I understand looking at the <a href=\"ht...
What are the possible 'types' available in SQL Server as mentioned in the 'type' column in the sys.master_files view?
dba
2017-07-19T10:08:17.570
[ { "message": "I have 1.8TB AX database.File Size : 1851427.75 MBFree Space : 502837.13 MBIf free spaces will be used in the future, I don't want to shrink. Because it's taking a long time. (and index fragmentation)Daily observations result:Day Free space 492.435,75 MB (26%)Day Free space 485.750,25 MB (26%)Day ...
SQL Free space management
dba
2017-07-19T11:12:57.180
[ { "message": "Followed this guide to do the PostgreSQL replication:<a href=\"https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-on-postgresql-on-an-ubuntu-12-04-vps\" rel=\"nofollow noreferrer\">https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-repl...
How to do PostgreSQL replication on CentOS 7?
dba
2017-07-19T12:08:20.317
[ { "message": "After deploying an SSIS solution I found that tempdb filled up all the remaining hardrive space (250GB). I was then able to shrink it to about 70GB, where it has stayed even after a computer restart (with the SSIS jobs disabled).Looking at this query:<pre><code>USE tempdb;GOSELECT t.name AS Tab...
What could cause tempdb to remain large after restart?
dba
2017-07-19T12:38:14.470
[ { "message": "I have one table which stores input from user, so to allow national characters I've set charset to utf8mb4.Then I have second table, which can grow really large (100+ millions of rows) and I'm 100% sure that this table will store only ASCII characters, so I've set charset for this table to latin1 ...
Two tables with two different charsets
dba
2017-07-19T15:55:50.443
[ { "message": "I am creating a cataloging system for rocks that come from all around the world. As part of this system, I need to handle the location of the where the rocks were found.The problem is that the location needs to contain the country, a sub-item (e.g. State, Province), possibly another sub-item (e.g....
Handle location in a SQL database
dba
2017-07-19T20:08:15.703
[ { "message": "<pre><code>select *from temp tpjoin a on tp.id = a.idwhere ( a.enddate between @startdate and @endDate or a.startdate between @startdate and @endDate)and a.id1 in (case when (isnull(@id,''&lt;&gt;'') then (select distinct id from #temp2) else a....
Handling case statement subquery returning multiple rows
dba
2017-07-20T15:11:44.727
[ { "message": "So I currently have an sql statement: <pre><code>Select room_no, category from help_desk where room_no = '133' OR room_no = '120';</code></pre>and it returns: <a href=\"https://i.stack.imgur.com/ZIR5w.png\" rel=\"nofollow noreferrer\">How would I write an sql statement that would return it like th...
How to write sql statement for following scenario?
dba
2017-07-21T15:17:43.513
[ { "message": "I have the following SELECT statement which I have simplified here. It actually takes 0.6s to run as it does some calculations based on two tables (table1 &amp; table2).<pre><code>SELECT table1.id,table1.lat,table1.lon, (SELECT id FROM table2 WHERE latitude=table1.lat AND long...
MySQL update based on main table data with cross table subquery
dba
2017-07-22T09:24:01.410
[ { "message": "Say I have 10k records in Customer table (MySQL or oracle) which has 10 columns. One is ID(primary key) and another is name(created index on it)Now I search for word customer whose name is Alex. My understanding is first DBMS will determine the row location for record name <code>Alex</code> and th...
Applying Index happens in memory or disc?
dba
2017-07-23T05:55:54.257
[ { "message": "In Powershell, I have some data that I am importing from a <code>.csv</code>, and some data points aren't always entered so I need to replace them with <code>[DBNull]::Value</code>.The problem is that when I go to use <code>Write-SqlTableData</code> I get this error:<code>Write-SqlTableData : Inva...
Can't write DBNull to SQL in Powershell
dba
2017-07-23T06:21:23.047
[ { "message": "I hope this is the right place to ask the following question, and I make enough sense what is my concern.I have a table: <code>mood_tracker</code>, where I save about the feeling user has each day. <pre><code>CREATE TABLE `mood_tracker` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mood_id` ...
Managing timezones for user action datetimes
dba
2017-07-23T23:19:05.603
[ { "message": "I am pretty sure that this is a simple matter and that it's answered but I seems like not able to find it online, or to phrase it correctly.I have a table (<code>ven_data</code>) that has a few columns: <code>id_v</code>, <code>lang</code>, more data columnsThe unique constraint here is <code>(id_...
MySQL store procedure use select responce in INSERT...SELECT where in array
dba
2017-07-24T16:04:46.960
[ { "message": "I have setup sp_whoisactive as a report in SS Reporting Services so people less familiar with SSMS can run it and see what is happening when needed. I have it working good and BUT I can't seem to figure out how to show the \"sql text\" column as a hyperlink in SSRS as it's shown in SSMS. Anyone ha...
sp_whoisactive in SSRS
dba
2017-07-24T16:08:58.767
[ { "message": "I'm involved with managing an application with a large number of SQL Server 2014 databases and am extracting table and index sizes in order to track capacity. I'm using the following query:<pre><code>select db_name() as DBName, object_schema_name(i.object_id) as SchemaName, object_name(i....
Minimal permissions required to read index size in SQL Server
dba
2017-07-25T02:39:11.087
[ { "message": "We are migrating database from Rackspace to Azure. Our databases were deployed on Virtual Machines in rackspace. In our queries we are using Linked server to other databases. Basically cross database query.problem is that after migrating databases, we are unable to use linked server queries as Sql...
Linked Server alternative in Sql Azure database
dba
2017-07-25T04:22:01.823
[ { "message": "I have the following PowerShell script I am looking to add a header to this results without having a duplicate per each iteration but I am not familiar enough with Powershell if anyone can point me in the right direction it would be helpful.<blockquote> $servers = 'E:\\DBA\\servers.txt' $outfil...
Add header to multi server or instance query (powershell)
dba
2017-07-25T18:05:55.713
[ { "message": "I have following input for which I need to calculate the sum of values for previous x number of weeks for each category.<a href=\"https://i.stack.imgur.com/sRmvs.jpg\" rel=\"nofollow noreferrer\">If the x is 3 the output would look like this:<a href=\"https://i.stack.imgur.com/HkxPZ.jpg\" rel=\"no...
Sum of previous n number of columns based on some category
dba
2017-07-25T23:13:51.020
[ { "message": "We have TWO of: your standard 2-node active/passive Windows Server 2008 R2 with SQL Server 2008 SP1 Cluster with 1 TB of RAM on the active node and 512 GB on the passive (same on both clusters).Both OS and SQL \"see\" the 1 TB of memory and additionally set the following: \"min memory\" setting to...
mysterious memory problem
dba
2017-07-26T06:36:14.343
[ { "message": "I need to get the space used within each database file across large numbers (1000+) of databases on a regular basis without hitting disk IO too hard.I thought I could simple call the <code>FILEPROPERTY(@file, 'SpaceUsed')</code> function or <code>sp_spaceused</code> - however, the disk IO spikes t...
Is there to get space used in files for SQL Server database without negatively affecting IO?
dba
2017-07-26T10:28:02.680
[ { "message": "Running an S0. @@version = <code>Microsoft SQL Azure (RTM) - 12.0.2000.8 Jul 21 2017 14:10:34 Copyright (C) 2017 Microsoft Corporation. All rights reserved.</code>The stored proc uses 3 tables. One main object with a relation to prices and a relation to features.<a href=\"https://i.stack.imgur...
Improve speed of stored proc with lots of inserts [Azure-SQL]
dba
2017-07-26T11:34:49.137
[ { "message": "I have a table which contains a non-clustered primary key. I intend to remove this primary key and create a unique Covering Index on the same column instead. Then The table won't have a primary key, but a unique covering index.I searched google but could not find a relevant topic. Is that fundamen...
Comparison between A non-clustered primary key and a covering index in terms of performance
dba
2017-07-26T16:04:58.613
[ { "message": "I generate graph data using Spark's GraphX library and I need an efficient way to store graph data. I have access to Apache Cassandra and ideally I want to store the graph data in there but the issue is I don't know how to efficiently store the graph structure in Cassandra. I have looked at Titan'...
What is an efficient storage method to store Graph Data from GraphX (Spark)?
dba
2017-07-26T17:49:32.773
[ { "message": "I use MongoDB 3.4 with WiredTiger storage engine on a replica set of 4 nodes.I shrinked a lot a documents by removing properties that takes most of the space, but the <a href=\"https://docs.mongodb.com/manual/reference/command/dbStats/#dbStats.storageSize\" rel=\"nofollow noreferrer\">documentatio...
MongoDB / WiredTiger: reduce storage size after deleting properties from documents
dba
2017-07-27T11:29:36.160
[ { "message": "Afternoon,I need way to get the query stats for queries that aren't procedures/functions/triggers. sys.dm_exec_query_stats only appears to contain these, i need to gather similar stats that are in this dmv but for just normal queries submitted by ssms/EF/Web etc.This is what i used and it returns ...
Get top SQL Queries that aren't stored procs/functions/triggers
dba
2017-07-27T15:58:37.903
[ { "message": "I have one query that takes several seconds to execute. I'm using version 5.7.19. <pre><code>SELECT SQL_CALC_FOUND_ROWS wp_posts.*, SUM( IFNULL( pvc.count, 0 ) ) AS post_views FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) ...
Optimize slow Wordpress Query
dba
2017-07-28T00:03:05.967
[ { "message": "Please provide the solution for the error message below<blockquote> Msg 824, Level 16, State 2, Line 1 SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:87552775; actual 0:0). It occurred during a read of page (1:87552775) in database ID 7 at offset 0x00...
SQL Server detected a logical consistency-based I/O error
dba
2017-07-28T11:54:06.920
[ { "message": "I need to store an array of 3D points in a column: latitude, longitude, altitudeWhat datatype would be required for this?Also, if I wanted to extend this in the future to include time (ie an array of 4D points), how could I do so?I have gone for a custom datatype, but I am not sure if this is wise...
Storing a 3D point array representing a flight path?
dba
2017-07-28T14:46:14.797
[ { "message": "We have a database that in the past couple of months has started failing when we run CheckDB on it during the maintenance window. When we re-run it after the failure it will complete fine each time. A little information about the environment before I detail what is happening and what we have done ...
CheckDB Operation failing and returning error
dba
2017-07-28T15:29:43.643
[ { "message": "Reference the attached screenshot:<a href=\"https://i.stack.imgur.com/tZ8os.jpg\" rel=\"nofollow noreferrer\">I created a non-root user, and gave it all privileges to a database. It now has <code>All Privileges</code> of <code>Type</code> -- <code>global</code> and <code>database-specific</code>. ...
Meaning of various user account privileges in phpMyAdmin
dba
2017-07-28T17:23:16.617
[ { "message": "We've outgrown our current server and decided to move to two servers, one to host our apps, and one to hold our database. We looked into clustering and we don't feel we need to scale horizontally just yet. What's the best way to connect to and secure communication between the database and app serv...
MongoDB - Stand Alone Server Security SSL or SSH
dba
2017-07-28T19:23:55.367
[ { "message": "Im a complete novice to Access (2013).Im doing some History research and thought it would be easier to use Access. I have created two table so far. <code>People</code>, Details info about them <code>Events</code> (historical). Both have different fields.Can I create a third table that collates all...
Joining two tables with different fields through a link-table
dba
2017-07-29T16:02:18.957
[ { "message": "I have 2 servers running Windows Server 2016 with Microsoft SQL Server 2016 Enterprise. I have created a fail over cluster in Windows and joined both nodes without Active Directory. Then I created an availability group with both nodes and everything is fine and the database is synchronized.Now I c...
SQL Server 2016 Always ON high availability group listener configuration
dba
2017-07-29T17:20:14.150
[ { "message": "I'm trying to implement Merge Replication between just two servers, a publisher and one Subscriber.Assume these tables :<pre><code>--Main table in PublisherTicket (id, userId, reqId, blockedDate, usedDate, returnDate, transferDate, ...)--On Subscriber (The fields are in Publication)Ticket (id, use...
Merge Replication customize synchronization cycle and its performance
dba
2017-07-30T13:01:23.177
[ { "message": "I have a multi-nodes Galera setup which is master-master. An API call to a web server A could write data to either database 1, 2, 3 or 4 (we are not using HaProxy). Another API call right after that could hit web server A again. However, the second API call couldn't find the record created in the ...
Galera multi-nodes Master-Master issue with READ right after INSERT
dba
2017-07-31T19:52:03.820
[ { "message": "I'm pasting section of <a href=\"https://github.com/major/MySQLTuner-perl\" rel=\"nofollow noreferrer\">MySQL Tuner result regarding MyISAM Metrics.<pre><code>[OK] Currently running supported MySQL version 5.5.57-0ubuntu0.14.04.1-log[OK] Operating on 64-bit architecture-------- Performance Metrics...
mysqltuner - Write Key buffer hit rate
dba
2017-08-01T12:03:40.030
[ { "message": "Every few minutes up to more or less one hour, the proc cache is being flushed (but not entirely!). If I run:<pre><code>SELECT count (*) FROM sys.dm_exec_cached_plans</code></pre>...just after clearing happens, the number of plans drops to a few hundreds and then gradually increases to more or les...
SQL Server 2016 SP1 CU3 clears the plan cache
dba
2017-08-01T13:09:52.900
[ { "message": "Previous question: <a href=\"https://dba.stackexchange.com/q/180270\">PostgreSQL function parameters JSON to TYPEI am trying to create a sample of code using <code>json_populate_recordset</code>, but it seems I am doing something wrong. I have created a test_GPS function:<pre><code>CREATE OR REPLA...
PostgreSQL function param json_populate_recordset ARRAY problem
dba
2017-08-01T17:48:10.930
[ { "message": "Sql Backup job summary:Hi, I have a backup job that take full backup first day of the month and take differential backup every 2 hours between 9am and 5pm everyday.Problem:While testing disaster recovery plan I found that after few differential backups size of differential backup reduced and when ...
Cannot find reason why differential backups size reduced
dba
2017-08-02T09:17:56.053