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
0answers
7 views

When there is a composite index and those columns are in query, does it use index seek?

I have a table staff having columns, name, year,month and date. I have a composite index on year,month and date. If I have a query like below, will it use index seek scan? select * from staff where ...
0
votes
0answers
6 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 ...
2
votes
1answer
20 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
10 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 ...
-1
votes
2answers
26 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
1answer
36 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 ...
1
vote
1answer
32 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
19 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
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 ...
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 ...
-1
votes
0answers
24 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 ...
1
vote
0answers
38 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
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
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
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
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 ...
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 ...
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
2answers
47 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
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 ...
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
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
2answers
41 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
1answer
68 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... ...
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 ...
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, ...
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 ...
-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
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 ...
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, ...
-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 ...
-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 ...
1
vote
2answers
22 views

Need to make MySQL's LOAD DATA LOCAL INFILE load large data faster

I need to load 4 million rows of data into a MySQL InnoDB table using LOAD DATA INFILE and would like to know if there are server configuration options I can tweak to get faster load. It took me 15 ...
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 ...
0
votes
2answers
31 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 ...
1
vote
1answer
19 views

making a where clause optional in a sql statement

Here is my current query: `SELECT `performers`.`hash`, `performers`.`alias`, `performers`.`date_updated`, `performers`.`status`, IF(`performers`.`status` = 'active', 'deleted','active') AS ...
1
vote
0answers
13 views

Explain unexpected result in MATCH () AGAINST ()

I have a database with a fulltext column name. I made a query SELECT name, MATCH (name) AGAINST ('breaking bad') AS score FROM files WHERE MATCH (name) AGAINST ('breaking bad'); So that I can see ...
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
2answers
31 views

Whats SQL Server NVARCHAR(max) equivalent in MySQL?

Using SQL Server you just have to give the "MAX" parameter to the length of a text data type, but in MySQL there's no such a thing. According to Ispirer: "n" is the maximum number of characters, ...
0
votes
0answers
24 views

Why is the transaction log file not truncated though its simple recovery model? [duplicate]

My database is simple recovery model and when I view the free space in log file it shows 99%. Why doesn't my log file truncate the committed data automatically to free space in ldf file? When I shrink ...
1
vote
1answer
45 views

How do relations work in NOSQL? [on hold]

I was using SQL in all my previous application and to understand the Parse.com db storage, I wanted to know NOSQL. I tried searching the differences between SQL and NOSQL for past 2 days & I ...
-6
votes
0answers
23 views

what the wrong in this stetment [closed]

Dim sqlQRY As String = " Select invqu FROM invodet WHERE invsun = '" & DataGridView1.Item(i, j).ToString & "' AND invon = " & Val(TextBox1.Text) & ""
-2
votes
0answers
12 views

This query returning different result sets [closed]

Hi is have this query (SELECT DISTINCT CONCAT (MONTH(`Date`),'-',YEAR(`Date`)) from wp_result_plugin WHERE Bet=$Bet AND month(`Date`) = EXTRACT(month FROM (NOW())) ORDER BY MONTH(`Date`) ASC LIMIT ...
-2
votes
0answers
19 views

Calculate percentage of a column group by 2 columns in pivot table format using oracle 11g sql [closed]

I would like to request help displaying count of a column and respective percentage of a column as in pivot table. I tried several options of which I yielded 18 rows when used kind of select first ...
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
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
0answers
11 views

How to Extract suffix from the table column names [closed]

I have 2 tables , 1 contains answers and columns are A1, A2, A3 so 3 in A3 means this is answer to the question 3. tblAnswers Personid A1 A2 A3 =============================== ...
-1
votes
0answers
22 views

Add one column from another table [closed]

I have query which works fine, but I wanted to Add one column from another table. Here is my query:- select Id,username,email,usertype,active,(CASE WHEN usertype='1' THEN 'Admin' WHEN usertype='0' ...
0
votes
0answers
33 views

How to extract common subqueries to simplify? [closed]

I have a query like this: select S.ID, S.name student as S where not exists ( (select course_id from course where department_name = 'Biology' ) except (select course_id from S where ...
0
votes
1answer
34 views

Why people often said nosql has better write performance than sql? [closed]

I have been hearing these comments all around the internet. But I cannot see a good justification for it. Agree that nosql use de-normalized scheme to store data, which does not require join (for ...