An acronym for "Structured Query Language" (it's not the name of a specific DBMS product), SQL can be used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. It can also be used to manage schemas and data ...

learn more… | top users | synonyms (1)

0
votes
0answers
4 views

How to setup a trigger for updated records

Prod database "Mother" Copy of database "Father" Here's my scenario I need help with: I have a database that has a table called User_Group table on our Production db "mother". The dev team wants me ...
0
votes
1answer
55 views

sql join without combining all rows

I've searched questions but can't seem to apply to my scenario. Please see attached code below. I am trying to join two subsets of this data but am getting duplicates/too many rows please see ...
1
vote
1answer
28 views

UPDATE/INSERT into Dynamic Columns

I am trying to update columns based on the value of the inserted column of the table 'my_table'. I want to be able to record the timestamp of the values changed. I am using the triggers but I can't ...
-3
votes
0answers
24 views

SQL Pivot by data

I have this procedure : alter proc rel_manipula(@inicio datetime,@fim datetime) as select A.codigoins, b.nomeid ,sum(a.qtd), a.dtmov from com_InsusTrans A inner join com_insus B on b.codigoins = ...
1
vote
0answers
12 views

finding out the Backup set physical name

I created a maintenance plan to back up two user databases and system databases over a month ago. I queried the msdb database to view the size of the backups using the following query. SELECT ...
3
votes
0answers
37 views

Timestamp-based index

I have a big database (200GB+) that contains some log info. And I want to speed up SELECT queries and stored procedures. I have a table with a GeneratedOnUtc datetime column, and have a non-clustered ...
2
votes
0answers
14 views

Normalization - removing transitive dependency

I am creating a rules engine which will be executed in code, but I have a problem defining a properly normalized database structure for it: There are templates from which rules can be derived Each ...
1
vote
2answers
3k views

Sum values from two tables ORACLE

I want to use two values, in two different tables, to be used as a total in a third table. For instance: table accommodation and flight Add value from acc_price with value from flight_price Add ...
2
votes
1answer
27 views

Update matching keywords from first table to second table in SQL

I have two tables where 1st table is Englishgermankwds_tbl and 2nd is Kwd_UploadRecored the data of the tables is as follows Table Englishgermankwds_tbl English_Keywords ...
-1
votes
0answers
11 views

How to convert DECIMAL to DATE in DB2 for iSeries SQL

I am trying to write a SQL query to convert DECIMAL to DATE in DB2 but below error is thrown. Error: [SQL0204] TO_DATE in *LIBL type *N not found Please assist me on this issue. The data type of ...
0
votes
0answers
2 views

Delete fabricante_producto_solicitud only if is not related to modelo_marca_producto

I have this related tables: It's possible, in one query, check if fabricante_producto_solicitud has relation with modelo_marca_producto or do I need to rely on programmatic way? I need some ...
-1
votes
1answer
26 views

How to select a record and update another record with selected

Say, I have a table: User User_key User_id User_name User_status State 1 001 Adam Active CA 2 002 Zack Active NY 3 003 ...
1
vote
1answer
10 views

Updating one table from another table where non-primary-key field is similar string

I have a database in Access that I am trying to fix (actually, I'm working on a copy of the original). There are two tables, one with data input errors, and a second that is a copy of those errors, ...
1
vote
2answers
62 views

Stored procedure - problem with merge - Insert

I am calling a stored procedure from my c# code . The procedure works fine for update, but fails for Insert. Is the following merge-insert procedure code correct? Any help is appreciated. Here is ...
0
votes
1answer
37 views

Update a set of SQL statements

dbo.MatchFirstName(@FirstName) and dbo.MatchLastName(@LastName) are table Value Functions(TVFs). Problem: In my Update statement i.e Update #Temp after Insert, I want only those rows to be ...
0
votes
3answers
54 views

Getting around the constraint “column must appear in the GROUP BY clause or be used in an aggregate function”

I'm using Postgres, which enforces the constraint that all columns in a SELECT...GROUP BY must appear in the GROUP BY clause or be used in an aggregate function. Lets say I'm modelling peoples' cars, ...
0
votes
1answer
34 views

Why does MariaDB 10.1.2 blow away MySQL 5.6.22 in sysbench?

Problem Maria DB is doing roughly twice the number of transactions that mysql is using standard oltp benchmark. The VM and db's are both fresh installs from vendor apt repos with default configs. ...
0
votes
0answers
14 views

DB2 LUW Timestamp differences in versions

Im new to DB2, my back ground is in MS SQL server 2000 thru 2012. I have a developer using Local DB DB2 LUW v9.7.500.4299 FIXPACK_NUM = 5 She is selecting some data from a table where the field ...
2
votes
1answer
733 views

SQL Server 2008 R2 cluster installation error

I was trying to install SQL Server Cluster (Launch wiard to install single node SQL Server 2008 R2 faliover cluster) .. The setup checks displayed no error and the installation started after all the ...
0
votes
1answer
34 views

Improving lots of Left Joins ( SQL Server 2008 - procedure )

This query is running with 8 minutes to complete. I'm trying to help the programmer with this task. I've created indexes and stats, update_stats and rebuild indexes but none of this is helping us. ...
-2
votes
0answers
36 views

SQL Server job to backup and restore database [on hold]

I need to create a SQL Server job that would run nightly and backup a database and restore the database with a different name. Example NorthDB (Original Database), NorthDB_test (backup database ...
0
votes
1answer
35 views

Locking the database to a single user so that other user wont change it

I am using SQL Server CE 4.0. In office the database (.sdf) file are on a server. When I want to change design of the database I have to copy it to local PC and access it since n/w connection to a ...
0
votes
0answers
17 views

Need help on transferring data from a PostgreSQL database to a future (to be decided) database!

(English isn't my native language) I'm doing an internship for school and my task is to theoretically describe the best way to transfer the data from their current database (PostgreSQL) that they have ...
0
votes
1answer
16 views

multiple table inner join didn't get expected values

Student_register table: regNo pro(HNDIT,HNDA,HNDFT) name start_day etc ... more columns Semester: regNo curSemmester(3,4,5) name The query I used to get values: SELECT ...
0
votes
1answer
19 views

Difficulty with nested query order & grouping

I'm trying to identify the count of objects a user updated during a given day, but only where the user was the final update. Each object can have multiple updates in a day from any user, but the ...
0
votes
1answer
142 views

Query to get reposts from people the user is following

I have a table posts where all the posts by users are stored, the structure of this table is as follows. | post_id | post_user | post_content | post_date | The users table is as follows. | user_id ...
0
votes
1answer
11 views

how to overcome these type of issues where null value inserted into primary key not null column in table

how to overcome these type of issues where null value inserted into primary key not null column in table
0
votes
1answer
49 views

Uexpected values inserted in table

I have a table called FunctionWeights which contains data as follows: My query is as follows: select @constVal = FunctionWeight from dbo.FunctionWeights where FunctionWeights.FunctionName = ...
1
vote
1answer
59 views

Query on 250 million records

I have a table with below structure CREATE TABLE [dbo].[ColumnValues]( [Id] [int] IDENTITY(1,1) NOT NULL, [ColumnId] [int] NOT NULL, [Value] [nvarchar](max) NULL, [OutputArea] ...
0
votes
2answers
40 views

SQL Server tuning: Disk queue to OS drive: How to optimize?

I expect to see the disk queue move on the data, tempdb, log and backup volumes. I do not expect to see the OS drive (C:) which has zero SQL files present, show disk queue impact. Assume it is to ...
0
votes
1answer
32 views

Converting sql into mongodb nosql

I am trying to convert oracle sql into its mongodb equivalent version. create table my_hll as select mod(ora_hash(n), 1024) bucket, max(num_zeroes(trunc(ora_hash(n)/1024)))+1 val from previous_data ...
0
votes
1answer
40 views

Exclusive access to edit rows [on hold]

I'm developing a program that allows users to view and edit data. My question: Is there tools (sql server tools, may be users/roles) to implement the following: There are two users: A and B. User A ...
0
votes
1answer
82 views

Handling empty fields

SELECT Name, SUM(Switch([Date] = DateAdd('d', - 7, DATE ()), NetAmount) )AS DAY1 FROM Customer GROUP BY Name My question is how to return the value 0 when the date is not present (an empty field). ...
0
votes
1answer
106 views

How can I optimize this Cross Table COUNT() mysql query?

I am trying to cut down the retrieval speed of this MySQL query. All instances of COUNT() point to the PRIMARY key of each field. Currently this query makes my MySQL hang. It seems ridiculous as I'm ...
1
vote
1answer
510 views

Tree structure hierarchical query sorting

I have the following structure of table. CREATE TABLE table1 ( serial_num integer NOT NULL, parent_num integer, parent_key text, key_ary_num integer[], level integer, rank integer, ...
1
vote
2answers
158 views

MYSQL joining 3 tables with left join

I have these tables: pupils: (id_pupil, name, surname, email, user, pass, level, class) incidents: (id_incidents, date, time, type_incident, comments, id_pupil, id_user, subject, id_trimester) ...
0
votes
1answer
27 views

Update does not working while select returns right results

I am trying to execute the query below: UPDATE( SELECT Ord.Completed FROM Product P INNER JOIN Order1 Ord ON Ord.OrderID = P.OrderID WHERE EXISTS( SELECT * FROM Delivery ...
2
votes
3answers
526 views

SQL Profiler - Insert values?

I setup an SQL profiler to run, but I am not seeing any values for updates/inserts. Is there a way to see them? All I see is stuff like this: insert into some_tbl(id, col1, col2, col3) values ( @P0 ...
0
votes
2answers
191 views

How can I optimize this query and support multiple SKUs?

My current query only can select one SKU at a time. I can leave salesite_id constant. If there is a way to also have varying salesite_ids that would be good too, but not necessary. Also any ...
-2
votes
0answers
11 views

which one is better for connecting vb.net to sql? wizard or ado.net coding? [on hold]

What is the solution for this picture? Data is not saving in SQL database. I think it happend when i added the grid-view.
0
votes
0answers
22 views

How can I track changes across 60 local databases with 1 million+ rows each?

The files are mdb and I have them locally on my computer. Just trying to track changes across the 60 databases. Realistically I want to compare two at a time and find the differences in the reports, ...
2
votes
1answer
23 views

How to pass multi-valued characters in SSRS Report?

I have a SSRS report that has 3 data sets feeding off one data source. The main dataset is a stored procedure that is aggregating some data based on a set of parameters powered by the other two ...
0
votes
2answers
31 views

Oracle custom week of the year numbering based on first Monday of the year

I have following sql for generating dates, I wanted to change week of the year numbering based on 'First Monday of the Year'. Hence numbering would be, 01-05-15 ---> 01 01-12-15 ---> 02 ...
0
votes
1answer
36 views

Long running query…only on replicated database

I have an issue I can't seem to solve and wondering if anything jumps out at you. I have a query that I got from one of our developers, it runs in about 5 seconds on our production database and also ...
-2
votes
0answers
31 views

Multiply operation/field causing the record set to 'ungroup'?

I'm trying to sort a query for a report but every time I add a Multiply operation to it the record set result becomes a mess and if I try to GROUP BY I get the legendary ...either an aggregate ...
1
vote
2answers
17k views

Windows could not start the SQL Server (mssqlserver) service on local computer error 17058

I'm working with virtual machine on the windows 8. There is a SQL Server 2008 on the virtual machine. And in the services; when I try to start the SQL Server service getting an error like this: Can ...
1
vote
1answer
60 views

Get all rows in table A even if no rows in table B in CROSS JOIN

I Have This query SELECT * FROM ( ( SELECT SUM(Auditoria.Importe - ISNULL(Auditoria.Pago, 0)) AS Deuda FROM Auditoria INNER JOIN Articulos_Auditoria ON ...
0
votes
2answers
81 views

write to SQL server from another server

I have 2 Windows 2012 virtual machines set up in Virtualbox - one called "AppServer" where I'll be installing applications, and another called "DatabaseServer" - where the application databases will ...
1
vote
2answers
2k views

Is there any way to force MySQL use Hash Join instead of Nested Loop Join?

According to the document MySQL Explain Output format, MySQL resolves all joins using a nested-loop join method. Is there any way to force MySQL to use a hash join?
0
votes
0answers
23 views

How to cast as type of a table column?

I have multiple views with union like this: select column1, column2 from mytable union select cast(extcol as nvarchar2(15)), cast(extcol2 as nvarchar2(10)) from exttable But later I change the size ...