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)

3
votes
3answers
21 views

Reseed identity column in all empty tables

I need to write a query that resets the identity on all tables that have an identity column and are empty.
0
votes
0answers
5 views

Why are some of my migrated tables showing “The given key was not present in the dictionary” in WebMatrix's interface?

I'm having an issue while using the SQL Server Migration tool to convert Access accdbs into SQL Server 2014 Express. I am converting the tables using SQL Server Migration Tool and I have a connection ...
0
votes
2answers
54 views

Is it sensible for a web app to log every DB command? [on hold]

Trying to figure out what my web app should log. From a security perspective and a storage perspective, does it make sense for it to log every SQL DB command? If not, what should it log?
-2
votes
0answers
13 views

Updating data from one database to another [on hold]

I have two database, PLAYEMASRTL and TmsEPly, I need to update the former with information from the latter. I am currently trying to use this update statement but am running into a lot of invalid ...
3
votes
1answer
49 views

MySQL: UNION query to get a line for each date

Table1 DATE SKU QTY 2015-06-20 ABCD 3 2015-06-20 ABCD 1 2015-06-21 ABCD 5 2015-06-23 ABCD 2 2015-06-20 EFGH 1 2015-06-21 EFGH 3 Table2 DATE ...
3
votes
3answers
140 views

Make a column for each count(*) in a day of the week

I have a table of people who are doing piece work. Every entry in the table has a user-ID, name, and a Date for each report they enter. I need to make a weekly report of what these people have done ...
0
votes
1answer
27 views

Query Access Question

With one table tblBids containing BidId field with the relationship bidID has multiple contractors from tblContractors, I am trying to create a query which will list each contractor and email address ...
1
vote
1answer
29 views

Order By with duration strings having time units

I have a SQLite database with a table "Rate" who has a column "timeToMaturity". This column contains strings such as : 7Months 26Days 3Years I'd like to order a query results by timeToMaturity ...
0
votes
2answers
49 views

Would like to know why this query is behaving this way?

I have an emp table, with schema and some initial values like below: emp_id | name | last_name | role_id --------+------+-----------+--------- 1 | hell | bell | 1 2 | well | ...
0
votes
0answers
19 views

Object refernce not set… Maintenance plans SQL server 2012

I need to perform a backup but while executing the existing maintenance plan, I recieve the following error message (also after creating new maintenance plan): Object reference not set to an ...
3
votes
3answers
135 views

INSERT/UPDATE in same query from previous SELECT with some singularities

I'm trying to perform a INSERT|UPDATE by selecting data from another DB and this is what I have so far: INSERT INTO pdone.reps (veeva_rep_id,display_name,username,`first`,`last`,email) SELECT ...
0
votes
2answers
44 views

SQL Server Database recovery from corrupt database [on hold]

Last week I backed up my SQL Server by using Backup Exec 2012. I named the file "SQL Server BAK" which contained copies of my SQL Server databases. A few days ago I lost some part of my data due to ...
2
votes
3answers
41 views

How to show multiple names for one record but not duplicate the record?

I have a database structure like so: Car - id - carname - image - category - status Parts - partid - partname CarParts - carpartid - carid(fk) - partid(fk) - amountid(fk) Category - ...
1
vote
1answer
15 views

update query field order guaranteed

Is an UPDATE query in MySQL guaranteed to execute the field updates in order that are presented? e.g. UPDATE `table` SET `first_to_update` = `second_field`, `second_field` = `third_field`, ...
1
vote
1answer
29 views

How can I pass object to procedure from trigger? [on hold]

I am using mysql 5.6. After insert or update, inside the trigger I am calling procedure, So how can i pass NEW and OLD object from trigger to procedure ?
0
votes
0answers
23 views

sql query group by data of certain range in continuous date

I want to Write a sql to query group by data within a certain range in continuous date.I'm usig T-SQL. Table: Date | MeterNo| Data | ---------|---------|---------| 01-06-15 | 12345 | ...
2
votes
1answer
26 views

Table structure for validating data using category and subcategory fields

I am creating a simple budget application, and the primary table will be a transaction table that contains things like the amount of the transaction, date, account, the category and subcategory (the ...
0
votes
2answers
32 views

Query of multi-valued field

I have 2 tables: Contacts and Helpers. The Helper field (which is linked to the Helper table) in Contacts is a multi-valued field so more than one helper can be selected and displayed in a report. ...
0
votes
0answers
23 views

Re-installing SQL Server 2008 R2

I uninstalled SQL Server 2008 R2 and I am trying to re-install. I get this error. Here is the part of the Detail Landing Page.txt: 2015-06-26 13:07:42 Slp: Running Action: ...
0
votes
0answers
89 views

Datediff with many dates causes poor performance?

I am a system programmer and entered the forum to understand a little more of the database. Currently I picked a query with a lot of data and I had to check there is a gap between today's date and the ...
0
votes
3answers
89 views

Is it better to use an ID (int) or a Name (varchar) as PK for a table? [on hold]

Let's suppose I have an ORDERS_LINE table and a PRODUCT table and the ORDERS_LINE table must have the information of which product was ordered. I prefer to use a Primary Key based on the Name since it ...
0
votes
0answers
32 views

SQL Server Management Studio greyed out

We have an issue where Object Explorer will not display. When we choose View > Object Explorer, New Query, or press F8, we get: A generic error occured in GDI+.
0
votes
0answers
13 views

Printing comments or statements when executing script to a output file using TOAD/ORACLE

Coming from a SQL SSMS enviorment, I would like to duplicate their 'Print' Command which allows you to print commands or variables while executing a query. I am looking for this feature to help ...
1
vote
4answers
61 views

SQL retrieve last elements of table using group by like behaviour

I am trying without success to retrieve the last version of all articles in a table. The table structure: CREATE TABLE `journalarticle` ( `uuid_` varchar(75) DEFAULT NULL, `articleId` ...
-1
votes
0answers
3 views

cannot get 2014 cluster to start up

I am trying to get node 1 of a new 2014 FCI to start up. I just did the first node install and at the end of the install it says it can't start up the cluster. I thought about the CNO and VCO and ...
3
votes
2answers
85 views

check when last backup was taken

Brent Ozar had an interesing newsletter on 2015-06-22; How do you manage dbas measuring backups, where he thinks that a good DBA should check when the last backup was done it was last restored ...
0
votes
0answers
14 views

unsigned right shift '>>>' Operator in sql server [on hold]

How to write unsigned right shift operator in sql server? The expression is like value >>> 0 Here is the e.g. -5381>>>0 = 4294961915
0
votes
0answers
22 views

http vs sql queries [migrated]

i have big problem deciding what approach to take, i have many pages on my site that uses tabs. for example a page with 5 tabs (horizontal tabs). now every tab takes data from different table in the ...
0
votes
0answers
33 views

How can I write a query to aggregate multiple strings into one field? [migrated]

I am trying to merge three tables. The first table has id and data_name, second table data_id, option_id and property, third table user_id, data_id. For example: first table +----+-----------+ | ...
1
vote
1answer
17 views

Select Distinct on subset of columns, name different set of columns to return

I am using PostgreSQL and have two tables: Table_A colA | colB | colC | colD | colE | colF | colG | colH | colI | colJ Table_B colA | colB | colC | columnD | colE | columnF | colG | colH | colI | ...
0
votes
0answers
13 views

SSMS SQL Server 2014 - Selecting BackupSets for a Restore takes a long time

I'm having an issue with SSMS SQL Server 2014 (before and after SP1). When I go and select 'restore database' from the server and select a database, it just sits there and spin and spins. More than ...
0
votes
0answers
3 views

Part of query is not properly performing in access design view(2010)?

So, I have been trying to figure out why this query is not running in the design view properly. I am trying to create a list of IDs of individuals who have an invoice(Gift table) between 1/1/2014, but ...
-1
votes
0answers
42 views

Need Review - Index Rebuild and Index Reorganize strategy?

I've written a block of code to design Index Reorganize and Index Rebuild strategy based on following recommendation. I'm considering only Clustered and Non-clustered index, not Heap. Does anything ...
0
votes
3answers
30 views

Error trying to SET a field when two fields in different tables match

I am trying to set catid to 584 whenever the rows in the tables ykz2d_crmery_deals and ykz2d_maps_integration have the same company id using the following query: UPDATE ykz2d_maps_integration SET ...
0
votes
1answer
24 views

Showing all values when at least match a given one

Given three tables items, genres and itemGenres; how can I filter out the items that have at least the given value while also outputting the rest of its genres. With this data INSERT INTO items ...
0
votes
1answer
41 views

Filter from the same user times

i have a table with user id-s, and many times for the same users, like this: id time 1 13:00:01 1 13:00:01 2 13:00:09 1 13:00.23 1 13:00:24 2 13:00:11 2 13:00:11 I ...
0
votes
2answers
27 views

SQL Server DB Restore Unable to browse directory

I have a problem with SQL Server 2008. When I try to restore a backup (located in the default location). This error appears. Cannot access the specified path of file on the server. Verify that you ...
2
votes
2answers
37 views

How can I Search for a string in all fields across all tables of a MySQL database?

I want to find a string and I don't know exactly which column and which table. How can I find it? Thanks.
1
vote
0answers
24 views

Count query help needed with unique records [migrated]

I have this following data-structure and I am trying to find unique ID where value Alphabets value Equals to A and B (i.e. select ID = 1, but not ID = 3 or 5). and also find unique ID where value ...
0
votes
2answers
38 views

Retrieve Data from a Specific Database [closed]

Goal: I want to retrieve the value of [data].[Mobiles] when you use a query document that is for the database [test] (use [test]) Problem: Based on picture two, I cannot retrieve the value ...
0
votes
0answers
10 views

Oracle: Recursively self referential join with nth level record

I have self referential table like this: id |level | parent_id ---------------------- 1 |1 |null 2 |1 |null 3 |2 |1 4 |2 |1 5 |2 |2 6 |3 |5 7 |3 |3 ...
-1
votes
2answers
24 views

SQL: Find row number with column entry of a specific string [closed]

I'm have an MS SQL Server 2014 Express database which I can search using a PHP script on my server to find if a string exists in the database. My SQL code is: IF EXISTS (SELECT * FROM TABLE WHERE ...
1
vote
2answers
48 views

SQL Server : trigger FOR DELETE

I want to create a trigger, which does not delete a customer if his name is Peter. How can I do that? CREATE TRIGGER trgCUSTOMER ON customer FOR DELETE AS BEGIN IF (SELECT name FROM deleted) not ...
0
votes
1answer
27 views

How to find the affected tables in a database? [closed]

I need to see the tables in the database that are affected after some changes are made from the front end application.
0
votes
2answers
59 views

How can i update my database from another database using temporary tables?

I want to update tables of my database using another big database every day with using temporary tables and without returning result. How can i update it? This my temporary table : use data_pro; ...
0
votes
4answers
43 views

Insert from Another Table + Removing Duplicate Entries in Postgres

I'm trying to insert data from one PostgreSQL table to another while removing duplicate entries but I'm having some trouble with the code. I have two tables I'm working with: mytesttable, which ...
1
vote
2answers
72 views

Group by month and year given yyyy-mm-dd as a date

I have a list of incidents and dates along with them, yyyy-mm-dd then a category. I need to order by the category (speeding tickets, DUIs, etc...) for each month in a year. This is what the two ...
7
votes
3answers
507 views

Use 'default value' in table when NULL

I am building a config table and want one row to be the default value. For the example, I have a list table of all my databases and a msg table of my return values. In the msg table, I have one row ...
0
votes
0answers
25 views

Error 1248: Every derived table must have its own alias [closed]

Please see my code, below. I get the error: Error 1248: Every derived table must have its own alias What am I doing wrong? CREATE PROCEDURE `insert_seance` (IN compared_id INT) BLOCK1: BEGIN ...
2
votes
2answers
40 views

Query Row Count for All Tables

I need help creating an MSSQL query to pass in every table name to the query below, which returns the number of rows. This is how I get the row count for a single table: SELECT Total_Rows = ...