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

what the wrong in this stetment [on hold]

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

This query returning different result sets [on hold]

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 ...
-1
votes
0answers
6 views

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

Hello DB users n Experts, I would like to request help displaying count of a column and respective percentage of a column as in pivot table,tried several options of which I yielded 18 rows when ...
1
vote
1answer
24 views

Can This Update Query Be Made Faster?

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
14 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
6 views

How to Extract suffix from the table column names [on hold]

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 =============================== ...
0
votes
1answer
15 views

Add one column from another table

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
9 views

How to extract common subqueries to simplify?

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
28 views

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

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 ...
0
votes
0answers
37 views

sp_WhoIsActive is not displaying results

I'm trying to use the sp_WhoIsActive stored procedure that I've downloaded from here: http://sqlblog.com/files/folders/release/tags/who+is+active/default.aspx I'm running the procedure without ...
2
votes
1answer
32 views

Can't seem to understand why STUFF isn't working

I've got two tables that store questions and possible answers. The questions table can have multiple possible answers to it. I want to display the possible answers it can have per question.. For ...
1
vote
1answer
25 views

Combine multiple query into 1 query

I have a message table that contains words field, array type, with random words of a message. Now I have an array of words [A, B, C]. I need to find the number of messages that the words contains ...
-1
votes
0answers
28 views

MySQL - Combining multiple rows as one in one table [duplicate]

I have one table employeeId | attribute | value 1 name John Doe 1 email john@example.com 1 age 28 2 name Jane Doe 2 ...
0
votes
1answer
19 views

How connect by is really working? How is it multiplying rows?

I know (on high abstract level) how hierarchies in Oracle works, but this one I do not understand. When issued following query: select rownum-1 as num from dual I've got one row as result. The ...
0
votes
1answer
13 views

Setting Key Constraints using a Diagram

I been using SSMS for diagramming my databases and I got used to create the key constraints with this tool. Now I started thinking, while going through related chapter of a book, "...maybe this is not ...
1
vote
1answer
13 views

Error when restoring SQL Server 2008 R2 backup on 2012

I am trying to restore a .bak file (backup taken on SQL Server 2008 R2, compatibility level 100). I am restoring the backup on SQL Server 2012 edition. I get the below error. Unfortunately the ...
1
vote
0answers
18 views

Best practices to segment people and attributes for advertising database

we have a database where we store people some attributes per person in the following tables: people (id, name, email, phone) people_attributes (id, person_id, attribute_name, attribute_value) ...
0
votes
0answers
45 views

Why are transactions long running?

My stored procedure has a transaction blog. I pick up a record from a database and process it in that transaction block. I noticed that my transaction log has grown in gigabytes. But my transaction ...
-2
votes
1answer
32 views

Generate create table DDL from any arbitrary select query? [on hold]

Is there a way, given any arbitrary select query like: select myfavoritenum, myfavoritetxt from tablewithmanycolumns and magically receive a create table statement: create table justmyfavorites ( ...
0
votes
1answer
25 views

Query calculating AVG per minute GROUP BY timestamp

I'm trying to query the average for each minute, so I can generate graph per 5, 15, 30 minutes. Here is my table, date stored in MySQL DateTime data type field. timestamp vif_2_rx ...
0
votes
2answers
75 views

How can I replace the following query with ISNULL function in SQL?

I have the following query. For performance optimization reasons I have been asked to replace the logic with ISNULL function in SQL. How can I achieve this? please advice. SELECT ...
0
votes
1answer
21 views

Insert sum of the row data of each record into separate column in postgreSQL?

I have a table id name class social science math Total 2 Max Three 85 56 85 3 Arnold Three 55 40 75 4 Krish Four 60 50 70 ...
0
votes
0answers
47 views

How can I replace the cursor in the below query?

I have this below query which calls a stored procedure that takes only 1 item's attributes at a time. But because of performance problems we are required to remove the cursor. How can I replace the ...
1
vote
1answer
43 views

Why is my transaction file growing when db is in simple mode and there are no waiting transactions

I noticed that my database log file has reached 160GBs. My database is in simple recovery mode and I used the following query to see if there are any waiting transactions. SELECT ...
0
votes
1answer
28 views

Insert date values in a created table

I have created a table using the below query CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0) NOT NULL, START_DATE date NOT NULL, END_DATE date NOT NULL, JOB_ID varchar(10) NOT NULL, ...
0
votes
0answers
16 views

How to segment account info and profile info?

I am putting a rough SQL database design together and have gotten stuck on how to segment information about the users. (Note before I get into anything, stored passwords are salted and hashed, I just ...
1
vote
1answer
18 views

Formatting SQL Source Code in SSMS [on hold]

There are several source code formatters for SQL in SSMS. I have tried a couple and found that are not configurable in terms of what formatting they do (e.g. indenting). Does anyone know of one ...
0
votes
0answers
6 views

Macro to search list JDE ERP

I have a list of Part numbers in a txt file. I need to get the matching Inventory number for each from our JDE database. Is it possible to build a macro in I-Series to search a JDE database for ...
1
vote
1answer
30 views

Call function where argument is a (sub)select statement

My function takes an int4 as argument and returns a table: SELECT * FROM test_function(545421); -- works fine SELECT * FROM test_function(SELECT customerid FROM tableX ...
0
votes
1answer
43 views

SQL Server Deadlock on delete

I have a query like this: with xx as ( SELECT [FilePath], ROW_NUMBER() over (partition by [FilePath] order by [FilePath]) as RowNumber FROM [dbo].[foo] ...
0
votes
1answer
18 views

Can combine five mysql statements into just one statement?

Can I combine all the five statements into just one statement? update mytable set myfield1 = replace(myfield1, '…' ,'-') ; update mytable set myfield1 = replace(myfield1, '‖' ,'|') ; update mytable ...
0
votes
0answers
13 views

Query JDE ERP Excel

I have a spreadsheet with a list of values, each matching to a particular part. I need to get a matching inventory number for each. My company uses JDE as an ERP. Is there anyway to use Excel (or ...
-2
votes
1answer
27 views

conversion failed when converting the varchar value 'JENNIFER FALCONER

I am trying to compare a status of an order. For example, placed, despatched, Invoiced etc from two table one is 'order' and another 'customer' ... while executing this simple join query(shown below) ...
0
votes
1answer
25 views

Select Multiple distinct with Order By Date Clause [on hold]

I have a MS-Access database tabel with follwing structure and Data : Now i want all the columns in my result with following conditions : TicketNo should not be repeated in result Result should ...
-1
votes
0answers
22 views

How to check if name has multiplr id's and count it as 1 [on hold]

in sql query, how can i check if a name has multiple id's and if it has, it will be counted as 1. For example i have 2 names and it has 2 ids, and then when i group it how can it be counted as 2 only ...
0
votes
2answers
26 views

Problem With update column in table [on hold]

there is my problem. I have to update column "date_to" , but only for those users who havent set their last "date_to" to value '3000-12-31' . Table looks like this : ID date_from ...
1
vote
1answer
44 views

What difference between these 2 SQL styles?

If I have a simple table named: conn_log in my Redshift/Postgresql In the performance of view, what difference between these two commands ? select t1.wifi_name, (t2.sconn*100)::numeric/t1.ttconn ...
-1
votes
1answer
48 views

How to remove duplicates and keep the one with the most additional information

I have a postgres table (postgres version 9.3.4) of addresses with duplicate addresses: Column | Type | Modifiers ...
0
votes
0answers
24 views

How do I create an after Trigger in sql for a price reduction?

So im trying to do this for a personal project of mine just as a hobby kind of thing. What i need help with is that im not sure how to put a SQL After trigger for something i want to try. What i have ...
0
votes
0answers
35 views

Decimal Data Type as Primary Key

One of my tables is set up like this: create table dbo.Source ( testID decimal (10,3) PRIMARY KEY , column 2 somedatatype , column 3 somedatatype ) Whenever I perform SSIS into this table ...
-4
votes
0answers
28 views

Why is this SQL statement giving me an error [closed]

I have an SQL statement which is giving me an error. The statement is below: create table design_parts ( design_name varchar(30), job_parts varchar(30), primary key (design_name), foreign key ...
0
votes
1answer
59 views

SQL Server : execute stored procedure from another stored procedure

I have two stored procedures. Proc1 executes a SQL statement and results a data table as a result set. I need to use the datatable in a select SQL that resides in proc2 as a datasource. like, ...
1
vote
1answer
17 views

Groups relationships - Detailed or Direct?

I have a Person model: PersonId Name ----------- ---------------- 1 Jessica 2 Jennifer Then I have a ShareModel which have the Personand an ...
-1
votes
2answers
15 views

Query to get the listener.ora path in Oracle 11G

Can anyone help me out with an PL/SQL query to get the path of the listener.ora file in Oracle 11G? I require it to be fetched from the Oracle DB only via an SQL query & not via the Operating ...
-1
votes
0answers
7 views

How to schedule a policy to run on multiple instances via a Central server [closed]

I have been tasked with how to schedule a policy to run on multiple instances via a Central server, I do have the policy created already on central server and i will like to schedule a job that will ...
1
vote
1answer
47 views

How to join SQL tables where value is Between min and max value

I am currently looking to join two tables together based on an IP and IP range. Both the IP and Range are currently stored as BIGINT. For example we have a table MasterData with IPs in integer ...
0
votes
2answers
20 views

how to make shapefile in geometry column of ms sql?

I was tried ogr2ogr command like this. ogr2ogr -f "ESRI Shapefile" "C:\temp\sqlexport.shp" "MSSQL:server=[RemoteServerIp];database=[dbname];User Id=[user];Password=[password];trust_connection=yes;" ...
-2
votes
1answer
20 views

SQL functions to return user ID [closed]

How to make MySQL function that will proceed user ID and return a full number of his friends? Could you help me, please?
0
votes
2answers
20 views

Transform 14 columns into 2 (SQL Server 2008) - Pivot/Cursor not helping

After hours googling pivot and cursors. I couldn't think or figure out how to do this. I have this query: declare @banco varchar(100) set @banco = 'CascVW' declare @tbltemp1 table ( ...
-3
votes
3answers
38 views

How work SELECT in database [closed]

My table has 8,400 rows of user information. Say I submit the query SELECT name FROM users WHERE name = 'jhon'; I know that 'jhon' is the 400th row in my dataset. My question is, will the DBMS ...