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)

0
votes
1answer
30 views

Is there a performance hit for querying two different databases?

I have two tables, A and B, which are located in different databases on the same MySQL server. I would like to create a derived table C from tables A and B, as an inner join between the two tables. ...
0
votes
0answers
5 views

SQL Query to compare (HL7) value at certain position in string based on delimiters (not position)

This is complicated by the fact that I don't know what DBMS the backend uses. I know it's Cache, but I don't seem to be able to do anything but the most basic commands. I cannot seem to SET or ...
1
vote
1answer
12 views

Regular expression in a SQL case statement

I have records formatted as such: CBS405/505 Fourth Week(Wtr Qtr) BR 404-504-604 Fifth Week(Fall Qtr) AP490-QB-09 Weekly Sessions(Spr Qtr) APR501 Fourth Week(Wtr Qtr) MP 300 Fourth Week(Wtr Qtr) ...
0
votes
1answer
9 views

Using If /then statements in SQL server computed column specification

I have two fields in a SQL Server database called "Species" and "Species _other" that stem from a front end data collection software dropdown values. I am trying to use a computed column using an ...
0
votes
2answers
24 views

How to use aggregate function and group by with inner join? (Postgres 9.3)

I would like to select "extra" payments made in association with normal appointments for a one week period and SUM them up by contractor when calculating payroll. Here's what I attempted: SELECT ...
0
votes
2answers
30 views

SQL Server 2008 R2 Replication not working - my 1st try

I am having difficulties when I attempt my first shot at SQL Server 2008 R2 Replication. Looks like I have login issues. How do you modify settings without having to start a new plan again? Please be ...
0
votes
1answer
27 views

Speed up procedure

I was wondering if this procedure can be executed faster. There are indexes on the joins and where's. Depeding on the size of product_id_CSV it takes approx. 2.5 sec. CREATE ...
0
votes
0answers
16 views

concept of foeign key from composite primary key in sql server 2012 [on hold]

Suppose i have 2 tables. Table 1 say tbl1 has composite primary key. Table 2 say tbl2 has foreign key, that has one of the primary keys of table 1. Can anyone provide a query on how to ...
0
votes
1answer
33 views

Unable to open SQL Server database file (.mdf)

I have a SQL Server 2005 .mdf file that I am trying to open in SQL Server Management Studio so I can add a field to a table, but I am unable to open the file. I can't say that I really understand how ...
0
votes
0answers
16 views

Sharepoint Database extraction [on hold]

Had Sharepoint running on SBS2003, server completely failed. I was able to use ubuntu live to boot server and pull data out of the RAID drives. I copied the MSSQL$SHAREPOINT folder over to a USB ...
2
votes
1answer
2k views

Error Code: 1133. Can't find any matching row in the user table

Im reading O'Relly "Learning MySQL" and it says that you can create a user in MySQL by doing just this: mysql> GRANT ALL ON *.* TO 'jill'@'%.invyhome.com' IDENTIFIED BY 'the_password'; Query OK, 0 ...
1
vote
0answers
34 views

Getting count of visits for multiple different outlets

I'm trying to get the distinct count of id that visited different outlets. I have more than 50 outlets so I don't think I can use the IN operator. CREATE TABLE transact ( year int NOT NULL, card_id ...
1
vote
0answers
17 views

how to disable and enable SSIS package using commandline?

I have a scenario where SSIS packages are deployed at the customer's site and they have some data issues. Because of this we are developing new packages to fix the corrupted data. When my new ...
0
votes
1answer
11 views

Switching a partition on a table with one to many relation

There is two main tables in database (SQL Server 2014) table1: ---------------------------------------------- id name datetime image table2: -------------------------------- ...
-1
votes
0answers
23 views

Generating new empty values while retrieving data from a database [on hold]

I have a Pettycash table Like this: PettycashId LedgerName OppositeLedgerName amount While I retrieving data like this: Select PettycashId,Ledgername,OppositeLedgername,Amount from Pettycash ...
0
votes
1answer
100 views

How to check mysql password change and other events logs

Recently someone change my phpmyadmin password and drop database I think it was sql injecting. Now I want to find information about this like when, how and who change my password Please tell me ...
1
vote
3answers
131 views

Text Storage and Database Design Optimization in a SQL Server Database

Given a database with a number of columns (c), where some of these columns contain text that is one of multiple values due to a set CONSTRAINT on the columns, what is the most efficient way to ...
1
vote
1answer
197 views

Profiling parameters

I was trying to fine the parameters of a query I suspect to be causing unnecessary logical read and eventually captured it in profiler, however parameters @p3 and @p4 are not listed. Is anyone able ...
1
vote
1answer
21 views

Shortcut for deleting a line of SQL

Is there a shortcut to delete your current line of SQL without highlighting the full line? I want to delete the line that my cursor is on without selecting the whole line. So in visual studio CTRL + ...
0
votes
1answer
30 views

Oracle SQL Complications With Multiple Triggers

Hey all so I am creating a DB that is used going to be used for managing utilities of a system. My DB has 3 tables: Users, Utilites, and Files (leaving Files table out because question shouldn't ...
2
votes
0answers
38 views

DB2 CASE statement faster with parentheses around entire WHEN

Trying to optimize slow queries, someone on my team come across this. Having this in our stored proc: CASE WHEN MYCOL BETWEEN @STARTNUM AND @ENDNUM AND RECTYPE = 'RO' THEN 1 ELSE 0 ...
1
vote
0answers
21 views

How do I cast a varchar to Bigint in DB2

I have a field which is varchar(25) and I need to create a join between that field and a field that is a bigint So I guess I need to convert the field into bigint aswell but it's giving me some ...
0
votes
1answer
137 views

MySQL-How to find that value in a column is subset with all other values in same column multiple time

I have a table named as Team where table contain 3 column (ID,Team,Task). Its datatypes are (INT,VARCHAR(255),INT). Below you will find a sample table where I would like to perform the query on column ...
2
votes
1answer
984 views

Split comma separated entries to rows

I have a Table like this: | ID | OtherID | Data +--------+-----------+--------------------------- | 5059 | 73831 | 5103,5107 | 5059 | 73941 | 5103,5104,5107 | 5059 | 73974 | ...
72
votes
8answers
12k views

Where are some useful SQL puzzles to teach SQL in a workplace?

I'm looking for beginner and intermediate level SQL puzzles, that I can point trainees at for practice. I'm aware of http://sqlzoo.net/ which is a great resource - is there anything else out there ...
2
votes
0answers
50 views

Query looks optimal but logical reads is huge

I run the following (really simple) query in SQL Server: SELECT MAX(PK_Field1) FROM MainTable kh WHERE kh.PK_Field1 >= '2014-12-01T00:00:00' AND kh.PK_Field2 = 1572 AND ...
1
vote
2answers
46 views

Running a T-SQL job under another user

I cant find my proxy user to "Run as" that user !? I am confused which kind of proxy user is appropriate to run a job with a simple T-SQL command. (I have created a credential and proxy but cant find ...
0
votes
1answer
96 views

Connect by prior - multiple fields and query efficiency

I have 2 tables one of which defines the hierarchy for the other equipment id desc 1 item1 2 item2 3 item3 4 item4 5 item5 6 item6 7 item7 8 item8 ...
0
votes
1answer
832 views

Machine account causing a Token-based server access validation failed with an infrastructure error

As the error suggests the SQL log is filling with the error: Login failed for user 'xxx\xxx$'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous ...
1
vote
1answer
101 views

SQL Server : scheduled JOB issue

I have one issue in my live server ... Issue is: I created a job for log file shrink & I have scheduled it for every day run with sa user When I run this job manually from Management Studio, it ...
0
votes
1answer
23 views

Inner join on array column in Postgres

In Postgres 9.4, I'm trying to pull the names of all columns that are involved in a UNIQUE constraint for a given table in Postgres. It looks like the names of such columns are contained in ...
0
votes
0answers
56 views

Select only rows that equal x but not x and y?

I'm having quite the challenge with selecting hierarchical data in mysql although I feel the schema should be optimized for it since it's based on the wordpress database model. I've got 4 tables... ...
1
vote
2answers
23 views

Can I select data inserted in the same uncommited transaction?

Maybe this is a dumb beginner question, but I cannot find an answer anywhere. Everywhere I read about the Transaction Isolation which solves the visibility of data within the concurrent transactions. ...
0
votes
1answer
31 views

Error: Incorrect usage of UNION and ORDER BY

I have this query: SELECT DISTINCT CONCAT (MONTH(`Date`),'-',YEAR(`Date`)) from wp_result_plugin WHERE Bet=2 AND month(`Date`) = EXTRACT(month FROM (NOW())) ORDER BY MONTH(`Date`) ASC UNION ...
0
votes
2answers
40 views

inner join select - group by?

I have 2 tables (Oracle database): ANEXA2A_TABEL1: id fk_id_anexa pet1 pet2 alt1 alt2 1 123 10 1 20 2 2 321 11 2 10 3 ...
0
votes
3answers
433 views

Mysql - How to Optimize Retrieval Time in a Table

I have query like this! which has 200 million Records in a single table.. I am using BTree Indexes in my table... mysql> select COUNT(DISTINCT id) from [tablename] where [columname] >=3; ...
3
votes
1answer
7k views

Joining 3 tables using SQL Query?

I'm having problems joining three tables. It works well when I use the same query for joining two tables (after removing LEFT OUTER JOIN C ON B.No = C.No). However, it doesn't work when I use three ...
1
vote
2answers
16 views

SQL Server total memory less than target memory, lot of extra memory unallocated

The situation is the following: We have a SQL2008r2 server (64bit on 64bit Windows) with SSRS installed on it. The Max Memory is set to 6GB, the server has 12GB total memory. The target server ...
0
votes
1answer
44 views

Does my ERD look well designed?

I am making a database at no cost for a local dance school. I'm still very new this would like to be sure that I designed it appropriately. From the front end, the parent will: fill out their ...
2
votes
1answer
52 views

Can this UPDATE be faster with indexes?

update line_items set product_id = dups.latest_product_id from line_items as li join products p on li.product_id = p.id join vendors v on p.vendor_id = v.id join vendorgroups vg on ...
0
votes
0answers
22 views

Designing multi-table notes

I have several tables (Providers, Items, Users) representing items that my users can comment on. In the OO mindset, if the above tables were classes, they would each be a subclass of Commentable, ...
4
votes
1answer
100 views

Combine multiple queries into 1 query

I have a message table in Postgres 9.4 that contains a words field of array type, with random words of a message. Currently I have millions of messages: \d messages Table ...
0
votes
3answers
40 views

How to retrieve all data from table if column value providing null value?

How to write a query: If country = ' ' I need to display all data in table. If country='algeria', it will display the particular data. I need both queries in a single query. I am getting result, ...
0
votes
0answers
37 views

Database deploy automation

In my company the developers use migrations for the schema changes in the database server and for install new databases too. More precisely they use Active Record (Ruby version). They have a project ...
-1
votes
2answers
55 views

SQL query to group different data seperately in the same table [on hold]

I would like to know how to construct an SQL query to group different subsets of data in the same table to get the count of each item in a horizontal result set. For example, the query against the ...
7
votes
4answers
370 views

Mathematical equality of two SQL statements

Is there a way to get check the mathematical equality of two SQL statements? I have two SQL statements: SQL_STATEMENT_1 SQL_STATEMENT_2 Running both statements on data and comparing the output ...
5
votes
3answers
200 views

Check if any of the values is in a subquery result

I have a complicated subquery that returns a list of order IDs. I need to get a list of customers who have these orders. The problem is that there are two ways of assigning a customer to an order (one ...
-5
votes
0answers
24 views

Comparison of columns with in the same table differed by date parameter [on hold]

How to write a SQL Expression to match the data of a dimention between the same table. regards dake
0
votes
1answer
20 views

ORA-01722 Error when running stored procedure

I am trying to run a stored procedure however when I run it with an a valid Number it gives me an ORA-01722 error. I checked to make sure that the columns in the where clause where the parameter is ...
-2
votes
0answers
34 views

How do I join these queries into one query? [on hold]

I have these below queries. How do I join these 3 queries into a single query? 1st query: SELECT TOP(1) @tmpOnlineCat = ac.AlertCatID FROM alert.AlertCategory ac WHERE ac.FkAlertID = 2 AND ...