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)

-1
votes
0answers
34 views

Query tuning and index creating [closed]

I am going to create indexes in one table using Oracle SQL Developer. The table has 60 columns, but on which column(s) do I need to create index(es)? Based on belevel or distinct or date or names or ...
0
votes
1answer
20 views

How to use explode mysql function in where condition with cakephp

I am using cakephp 2.6. I have payment_method fields in mysql table which store the values like 54,52,59,57 . Now my question is that how can i check if new posted payment method id is available in ...
0
votes
1answer
27 views

Need to run query if value in tb1 col1 is 1 and value in tb2 col1 is 1 than run the Insert into query otherwise don't run it [closed]

Two servers. Server A and Server B both has database named KPS. KPS has two tables complaint and attachment. KPS database on server A gets the value from the Web. both table if the submitted value = 1 ...
1
vote
0answers
124 views

Generally unsolvable problem? How to ORDER BY aggregated columns GROUPED BY many possible columns very fast?

Is there general solution or some best practises or at least some vague hint, how to solve following problem (general, but concretised in following example)? I think this must have been solved many ...
1
vote
0answers
18 views

SQL Agent job history not found for few jobs

I have;backup ,rebuild Indexes , Update Stats and few other jobs like space alerts, replication jobs etc which run frequently on SQL Server 2102-SP2, Build Number:11.0.5058.0 and I do not see any ...
2
votes
1answer
49 views

Selecting max(date) from union query

I am having a bit of trouble getting accurate results from a query that looks to me as if it should work. RDBMS is MySQL. I am trying to get the max last login date from a union select on three ...
0
votes
2answers
103 views

How can i use the same query for all codes?

I use this query in PHPmyAdmin, i have date that contain(date,hour),supp, price and code_product (it repeated many times) : I want to return the last price for the last date of product code ...
3
votes
1answer
43 views

SQL Server 2008 R2 Mirroring issues

I have this very frustrating problem that I've been trying to figure out for almost a week now. I have two SQL Server 2008 R2 STD w/SP3 box running on Windows 2012 R2 with two instances each, Server1 ...
1
vote
3answers
86 views

Get rows changed between two dates (latest and previous)

I have a table _sync_history with this data: +----+----------------+---------------------+ | id | object_name | sync_time | +----+----------------+---------------------+ | 1 | territory ...
12
votes
1answer
871 views

Best way to write SQL Query that checks a column for non-NULL value or NULL

I have a SP with a parameter that has NULL as default value and then I want to do a query like this: SELECT ... FROM ... WHERE a.Blah = @Blah AND (a.VersionId = @VersionId OR (@VersionId IS NULL AND ...
0
votes
2answers
66 views

Two columns into three and add rows automatically

I need help with a SQL query that it is very complex for me. I have a table with two columns where the first column is the order_id and the second column is for the products added to that order. It ...
0
votes
0answers
8 views

how to find and replace text in phpmyadmin

we are migrating from one domain to another domain. usually we will foloow the procedure of "open the database file in notepadd++ software and find and replace old-doamin-name to new-domain-name. ...
3
votes
1answer
22 views

Stored procedure deployment - push or pull into database? [closed]

Using stored procedures as part of an ETL process to populate tables in another database, which method would be considered a best practice (if any) in terms of deployment, maintenance, visibility and ...
0
votes
0answers
15 views

Azure Database Sync with warning on row update

To create a real time backup DB in Azure, I have used the Azure sync group. What I have noticed is that if I edited one of the rows in any table (let's say, the customer's name) , I receive the ...
0
votes
1answer
48 views

Performing “dummy” queries in SQL

I'm working through the book SQL Cookbook and there's an example where the author uses a query which is purely cosmetic (it's after the first union all statement): select ename as ...
1
vote
1answer
26 views

How to update/insert/inject nodes into XML

I have an application which stores optional Site information in an XML field. Sample table: CREATE TABLE [dbo].[Sites]( [SiteID] [int] IDENTITY(1,1) NOT NULL, [SiteName] [nvarchar](80) ...
2
votes
1answer
28 views

delete records in one table based on multiple column values in second table

I need to insert and delete records in table 1 based on the data in multiple columns in table 2 Example: Table1 and Table2 have identical columns = address, city, state, zip Table1 is the master ...
1
vote
1answer
45 views

Full text search on multiple joined tables

I'm trying to set up a full text search in PostgreSQL but coming across the problem that the more tables I join to the query the fewer the results I get back. The tables I am trying to join are: ...
0
votes
2answers
50 views

Two select in one query [closed]

how to select for this output: A | B1 | B2 | C | D SELECT table1.A, table2.B, table3.C, table3.D FROM ...
1
vote
3answers
58 views

SSIS: How to check if a record DOESN'T exist in flat file but exists on the database

I am working on preparing an SSIS job where I am importing a .CVSV file to OLE DB destination (sql database). We are going to get these files on daily basis. The .CSV file contains records of doctors. ...
1
vote
0answers
43 views

MySQL Get first and last day of multiple records

I have a table HC_RSPI_data: | RADIO_TYPE | HOP | TOWARDS | RSPI | TP_NAME | DATE_TIME_END | TIME_LENGTH | RLTM_min | RLTM_max | ...
0
votes
0answers
17 views

Converting Legacy SQL Server 2005 Stored Procedure to Transaction based for parallelism [closed]

My task is to convert a legacy stored procedure written in SQL Server 2005 so that it can be used in parallel (multiple executions from different users). As of now the stored procedure is designed ...
0
votes
1answer
29 views

MySQL Select additional rows if initial query has specific column value returned

I have this sample DB table: id type c_owner_id c_linked_id 1 parent 1 2 2 parent 1 3 3 related 2 3 My script is provided a c_id. I SELECT out all rows ...
0
votes
0answers
11 views

Reset default value for many foreign keys in SQL Server

I need to reset the foreign keys default values to null for a big database by using some sql queries. My research in the stackoverflow website got me to drop the existing default values contraints and ...
1
vote
1answer
28 views

Creating a relationship between one field in a table with two fields in another [closed]

Is the picture below the only way to create the relationship described in the title with referential integrity? Why does Access not allow me to do this without the "duplicate" table? Thanks!
0
votes
1answer
36 views

Cache statistic data in SQL Server

Currently my team develop additional web app to let customers analyze user statistics to theirs portals. So we have a table with all logins. It contains about 100 millions of rows. One user could ...
-3
votes
0answers
52 views

Query to store the current date and time in a specific time range [closed]

I want an SQL query to create a table to store the current date and time (time is between 9:00 to 16:00). This is my table: utime Ltime ---------------- ---------------- 2015-07-21 9:00 ...
1
vote
3answers
68 views

How can i return the date of max id?

I want to select the max id_product and date that corresponds to this max id. my problem is that it returns the max id_ product with a different date. I can't use the max(date) because it will return ...
0
votes
2answers
28 views

Basic SQL question about setting constraints

In code such as the following, what is the need to write constraint pk_dept primary key (deptno) if just simply primary key (deptno) works? Is pk_dept something the database uses internally, since it ...
1
vote
1answer
38 views

Cannot connect to SQL Server database regardless of connection string

I'm having a tough time to connect to a local SQL Server instance within a C# app. I can connect to external databases on other servers, but I need to be able to use my own local database. The ...
2
votes
0answers
21 views

Replace part of URL only if doesn't contain a given part [migrated]

I need to replace all URLs containing 31.media.tumblr.com with 41.media.tumblr.com. But if URL 31.media.tumblr.com has .gif in it, it must not get changed. here's my code;, but it changes everything ...
1
vote
2answers
31 views

Include logical key on each table vs. join

I'm designing a database that is used to track an inventory item through its lifecycle. I'm currently relating my tables using the previous lifecycle event's ID (for example, a shipment contains the ...
1
vote
1answer
41 views

No rows in sys.dm_exec_procedure_stats for a particluar stored procedure

I am running DMV queries to get stats for my stored procedure, but I am not finding any rows against this SP under sys.dm_exec_procedure_stats. Please suggest what could be various reason for this ...
2
votes
2answers
56 views

Cannot build correct SELECT in MySql

Please help me to create a correct MySql query, which I failed to do. I have 2 tables in our DB: CREATE TABLE IF NOT EXISTS `user_audit` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, ...
1
vote
0answers
16 views

Why do async_network_io wait types occur?

Last week something strange happened on our database. All of a suddon, the application blocked for our users which were not able to save new entities etc. After looking at the Activity Monitor of the ...
1
vote
1answer
40 views

Mysql trough access

EDIT I solved the half, that i made a pass through query, so now I only need this: (Licenszek.verz_id)=[Forms]![Hasznalat]![verzio]; to be implemented To the pass trough, ot be the passtrough and a ...
2
votes
1answer
57 views

How to full text search worked with special character like “of”?

How to search with fulltext search if keyword has special character like "of", "-" ...etc select * from table1 join CONTAINSTABLE (table1,(Title,Description_HTML), '"of" and "Department"') tb2 on ...
5
votes
1answer
126 views

Rolling sum / count / average over date interval

In a database of transactions spanning 1,000s of entities over 18 months, I would like to run a query to group every possible 30-day period by entity_id with a SUM of their transaction amounts and ...
2
votes
1answer
30 views

Select columns dynamically from sql server table

Lets say I have a table that actually store record which looks like Create Table dbo.Info ( SN int primary key identity(1,1), FirstName nvarchar(50) not null, LastName nvarchar(50) not null, ...
1
vote
1answer
27 views

Procedure to read from crontab like table and populate another one periodically

Postgres 9.3 Debian 7 I'm working on a mobile game project (poker like) where an admin user can register a recurrent tournament. As it's recurrent, I modeled it crontab like as follows. ...
2
votes
2answers
121 views

Oracle 9: Convert date from mm/dd/yyyy hh:mm:ss format to iso8601 formatted datetime [closed]

Note: I only have read access to this database. I need to convert an Oracle 9 date type from d/mm/yyyy hh:mm:ss format to the iso8601 standard. Like the example below: 4/22/2015 12:02:56 AM => ...
1
vote
0answers
29 views

How to resolve Error 7311 returned by a job running against a linked server?

I have a job and a linked server. The job was working fine for a while, but recently I started getting this error message and I couldn't find a soloution for this. Executed as user: ... Cannot ...
0
votes
0answers
24 views

SQLite table design for PK and/or UNIQUE

I'm trying to design a table in SQLite3, where I can perform these 2 actions. INSERT new row where a unique primary key is created. And INSERT new row with an given primary key Think of a ...
1
vote
0answers
19 views

Check for a value from table 1 in table 2 [migrated]

I am struggling with how to do this and the examples I have found seem overly complicated for what I need to accomplish. I have two tables in separate databases. I need to see if Db1, table1, column2 ...
2
votes
2answers
67 views

Why would you put Identity Increment other than 1 in SQL? [closed]

In SQL Server, you can set the increment of an identity column other than 1. In what situation would you do that?
2
votes
1answer
64 views

Avoid joining to the same table multiple times

I have two tables: CREATE TABLE one ( id int4 primary key, p_id int4, k_id int4, c_id int4 ); CREATE TABLE two( id int4 primary key, p_id int4, k_id int4, t_id int4, pos int4 ); Table ...
-1
votes
1answer
67 views

Group by creating problem in Ranking of player [closed]

CREATE Table dbo.[#TMP] (UId uniqueidentifier, Points int, DC datetime, CId int, Username nvarchar(50)) ...
0
votes
1answer
33 views

Count in an other table and show only theese records in query which has more than they used in other table

I have for example 2 tables: used(us_id, code_id); codes(code_id, amount) I want something like this: If for example I have 5 eggs, and egg code is 1, then if the used table have reached 5 of ID ...
0
votes
0answers
15 views

how to get tag record with its descriptor from pi database?

I want to get the data with tag, time ,value, descriptor from pi database, but it seems tag record and its descriptor are stored in different database. tag, time ,value is stored in database ...
1
vote
2answers
153 views

Group or Order SQL output into a single row

I want to display each persons contact info and their commissions in a single row as oppose to multiple rows. Commission Table ID COMMISSION DATE ...