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)

2
votes
1answer
223 views

How to update a table with a stored procedure with XML parameter in SQL 2008?

I have the following Stored Procedure query. This query is incomplete. I need help completing this query. Problem: In this SP, I am receiving a well-formed XML string into the SP. My goal is to ...
0
votes
0answers
24 views

Using Code to Access Database Dump via pgAdmin

I looked over this question on how to import a data dump using pgadmin and found the following code: CREATE OR REPLACE FUNCTION db_to_csv(path TEXT) RETURNS void AS $$ tables RECORD; gmdeclare ...
1
vote
1answer
47 views

Will SQL charset wildcard query work on Oracle database? [closed]

I am trying to run the following query SELECT * FROM GEEKYBRAINS.admin_emp where ename like '[sm]%'; It results in an empty set. The admin_emp table has the following data though. I am running ...
0
votes
0answers
22 views

I want to uninstall every program that says “Microsoft SQL” in front of it [duplicate]

I just uninstalled SQL Server 2012 but there is a registryload of Microsoft SQL... entries in the Programs and Features. I want them all gone. I've had issues previously uninstalling them in the ...
0
votes
1answer
34 views

What does normalization say about storing data from objects that use a decorator pattern?

I am just curious as to what the best practices are for storing the data from objects built using decorator design. I have a base class and can decorate it with A, B, and/or C, with A B and C having ...
1
vote
1answer
28 views

Verify failed SQL Server connections to instances on a given server and email them

I am trying to monitor the SQL Server instances on standalone server / cluster server. I would like to setup something from commandline to check for connectivity to each SQL Server instance on the ...
0
votes
0answers
18 views

Modeling attributes relations in RDBMS/NOSQL?

I have a table to hold the relationship between attributes and documents: I need to support the following queries : give all documents where attrib X='value' give me all documents where attib ...
1
vote
1answer
54 views

How do you drop an unnamed check constraint in a PostgresQL table?

I created a PostgresQL table but I added an unnamed check constraint on one of the columns: CREATE TABLE FOO ( id serial primary key, price_range smallint CHECK (price_range > 0), url varchar(255) ...
-1
votes
1answer
90 views

SQL Server CE tools to modify database in network share

I am using SQL Server CE 4.0 SP1. I am using Web Developer 2010 Express to connect to database and perform operations like creating table, modifying column etc. But we cannot connect a database in a ...
0
votes
2answers
60 views

joining same table without a common field

Oracle 11g/SQLPLUS Given single table TABLE with three fields ID, PARM, VALUE, I want to select and group by based on different values of VALUE E.g. ID PARM VALUE id1 accnt France-1 id2 ...
1
vote
0answers
54 views

Defragmentation of SQL Server 2008 indexes

I hate asking this question, but I am having issues defragmenting indexes. I keep using the various defragmentation methods for defragmenting a SQL Server index such as DBCC INDEXDEFRAG and DBCC ...
2
votes
1answer
52 views

Auditing/Logging Help

I'm working on a request to start logging some additional data for PCI compliance. I need to log who, when, and what changed on a set of tables. I set up SQL auditing which would work fine except ...
6
votes
1answer
102 views

Looking for a set-based solution for a rolling 30-day period

I have a stored procedure (MS SQL Server 2008 R2) that needs to see if 10 points/sales fall within a 30-day rolling window. So far, I have a solution that works, but it's not a "proper" solution as ...
2
votes
3answers
117 views

Get last full backup and transaction log backup for each database

How to write script or a query that will display the last full backup and the last log backup for each database on each of the production servers using the system table "backupset" and related backup ...
0
votes
1answer
45 views

same table on different commands (inner join)

Testing some commands of MySQL, I've come across these two comands resulting on the same table. Command 1: select sales.relatory_code, sales.date, destiny.exportation_name from sales, destiny where ...
2
votes
1answer
199 views

Alter table Statement Failed -Msg 207, Level 16, State 1

I wrote a script to add a column in a table and on successful execution update its values. I know it’s just a simple script but what is wrong with the ‘IF NOT EXISTS’ statement why script between ...
2
votes
1answer
84 views

I can't create relationship in my database sql server

I have designed a database for my website. It has 3 tables: user, topic and comment. A user has many topics (or articles) A topic (or article) has many comments A user has many comments I ...
1
vote
0answers
96 views

Backup and FTP SQL Server databases

We plan to backup our SQL Server 2012 databases every night, FTP the backup files to our test servers and restore them. Then deploy the latest schemas to those databases. The reason for this is so we ...
1
vote
4answers
64 views

PostgreSQL execute a default query when no row are returned

I need to calculate the average score of a list of userId. I have a table user_place_score: (user_id, place_id, score) Sometimes I do not have the score (no row for (user_id,place_id) in the ...
0
votes
1answer
39 views

Aggregating two queries and returning a COUNT of some permutations

Hopefully the title can make sense to somebody, so I can get somebody working with a database (BigQuery in my case) to look into into. Given two quarters, I need to find out the # of orders placed by ...
1
vote
0answers
54 views

Does partitioning help if you don't query on the partition value?

Say I have an orders.Order table that is partitioned on CreatedWhen (a datetime column set to GetDate() when the row is created). The table has over 10 million rows and the partition is quarterly ...
0
votes
3answers
85 views

Remove duplicates from different columns

I'm trying to remove duplicates from a set, but the duplicates are in different columns, so for example with this table: ColA, ColB, ColC, ColD ---------- 1, 1, 'ABC', 'DEF' ---------- 1, 1, 'DEF', ...
0
votes
1answer
74 views

SQL access query to count and delete rows > n

Can someone help me with a SQL (Access) query to delete all rows greater than n entries ordered by ID? I.e. say I have 1200 rows of data with ID incremented . I need delete the first amount leaving ...
-4
votes
1answer
67 views

Distinct count of 5 different fields based on multiple values?

I'm not sure how else to explain this so here is an example of what I am trying to accomplish. The problem with this, as you will quickly notice, is that there are repeats in the results. and there ...
0
votes
0answers
41 views

Locally connecting to SQL Server 2012 using Windows Authentication

I have a SQL Server 2012 cluster which I've updated with SP2, and since the update I can't locally connect to the server using Windows Authentication. Yet, I can connect using same credentials from ...
1
vote
1answer
64 views

T-SQL Create Query - Compare and Calculate

I got a mini fantasy league (NBA) and would like some help with a query that turns averages into "ranking points". Basically I got two tables. Source table: This is a table with statistical per ...
6
votes
3answers
428 views

Using DISTINCT in window function with OVER

I'm trying to migrate a query from Oracle to SQL Server 2014. Here is my query which works great in Oracle: select count(distinct A) over (partition by B) / count(*) over() as A_B from MyTable ...
0
votes
1answer
46 views

selecting table1 and table2 with single data row and table 3 with multiple data rows

I want to retrieve data from table1(payments), table2(properties), and table3 (property.assessments). See my visual representation below: tables screenshot Snippets: SELECT a.payment_id, ...
1
vote
0answers
48 views

Is there any way to improve this code?

SELECT tblstud.studid, tblsched.ip FROM tblstud LEFT JOIN tblstudsched ON (tblstud.studid=tblstudsched.studid) LEFT JOIN tblsched ON (tblstudsched.schedid=tblsched.schedid) ...
1
vote
1answer
79 views

Get all the data between Characters [closed]

I am trying to extract all the variable from the following string; string = 'factor1|factor2|factor3' This is just a test string. In real string, I do not know the number of factors. What I want is ...
1
vote
1answer
34 views

Initialize replication from multiple split backup files

We are creating a new Node within our existing P2P replication setup. To be able to create the backup and copy the files I am Backing up to 9 files - each will be about 72Gb: e.g. BACKUP DATABASE ...
0
votes
2answers
80 views

Stored Procedure never completes with Exec, but i can run the Query in SSMS

Im with a problem here. If i run "exec pr_BuscaLog -2', it will run forever ( days, without end )... BUT, If i select the Query and F5, it runs in seconds. I updated STATS but it didn't work. Some ...
0
votes
0answers
31 views

Rebuilding of Index in LogShipping DB in SQL Server 2008 R2 Standard version

Recently I joined the new organization and I am new to Log Shipping. After joining new company I found the fragmentation size of clustered indexes approx 256 indexes more than a 80% and I got the task ...
0
votes
1answer
35 views

import text file getting command is not allowed with this MySQL version

here is my table CREATE TABLE cities ( country CHAR(2), city_ascii VARCHAR(100), city VARCHAR(255), region CHAR(2), population INT UNSIGNED, ...
0
votes
0answers
51 views

Help with Joins - Cartesian Product

I have 5 regions that each contain 1 store and 1 warehouse. I have a table that contains the regions and corresponding stores and warehouses. I also have a table that lists the inventories of both ...
2
votes
0answers
24 views

Snapshot Agent - Transactional Replication - Why a complete snapshot?

Often, I will add a single article to an existing transactional replication publication. I then start the snapshot agent to copy the new article and it's data over to the subscriber. Most of the time, ...
1
vote
2answers
78 views

How to List SYNONYMS that no longer point to a valid object?

I have a table (OBJECTS_TO_UPDATE) with several objects I need to update, some are SYNONYMs for objects that no longer exist. I want to create a query to list them. But I am stuck. My table ...
2
votes
2answers
181 views

SQL Server DROP Database which is in a long roll back process

I have a DataBase that is taking very long to rollback a transactions. Which could be normally because it is rolling back a hugh amount of data. However I have the scripts to create the DB again and ...
0
votes
2answers
79 views

what could be the Best practices with very very large amount of data [closed]

I have a question on building a solution.I have a few txt/csv file having huge amount of data approx 30000000000 rows .By size they are 1.5 TB.The tables based on these data are only for lookup,I ...
0
votes
1answer
30 views

Count values of a column

I've got two database tables: Persons id user product 1 1 3 2 1 5 3 1 7 products id kilo 3 8 5 15 7 3 I'm wondering how to count values from a ...
1
vote
0answers
161 views

SQL Agent After installation not able to start

SQL Server 2012 SQL Agent will not start after installation. Checked permissions, on surface configurations, all OK, have tried to run it as another account no Joy. The error i am receiving is the ...
0
votes
1answer
93 views

Behaviour of RAISERROR within a TRY/CATCH within a loop

I have just encountered a section of SQL that is behaving not as I would expect (See below for a distilled version of the SQL in question that demonstrates the problem pattern). (This is on SQL ...
1
vote
1answer
57 views

Correct way to uninstall SQL Server 2008 ( or above )

Since University I've been facing this problem... How do I uninstall SQL Server? What I've done is: Delete everything in "control panel" related to SQL Server. But, is there a right way to ...
1
vote
1answer
39 views

“No Loop” Constraint for hierarchical data in postgresql

I've got table like this in postgres: id primary key parent_id foreign key on id some data columns I need no a constrain which prevents cycles on the parent relations. There might be more tree in ...
1
vote
0answers
35 views

adding a new partition takes a long time

I am adding a new partition and it takes too long to get this task done. ALTER TABLE attribute_usage_information ADD PARTITION ( PARTITION AUI_2015001 VALUES LESS THAN (735964) ) I am new to MySql ...
0
votes
0answers
56 views

Hsqldb and tomcat - permission denied or .lck file not found

I have an app running on tomcat7. For the database purpose, I am using hsqldb(1.8.0.7). In the webapp, I have several sql commands I want to run. However, the schema is not loaded from the app. I do ...
0
votes
1answer
28 views

Will canceling InnoDB compression that's already in progress corrupt data?

I have a 155GB table that is in the process of being compressed. ALTER TABLE $table_name ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; This compression has been running for a long time and is impeding my ...
0
votes
1answer
58 views

How to get average according to last update time?

There is table - Item below, how can I get the average Value according to its 15 minute value from last record time? I am using SQL Server 2008. Table -- Item Table 15min_AVG
2
votes
1answer
93 views

Should database be denormalized if I need an index across multiple tables

I have a catalog of album and song names. The song has a foreign key to the album table. I expect queries like: SELECT * FROM song s JOIN album a ON a.id = s.album_id WHERE LOWER(CONCAT_WS(' ', ...
0
votes
0answers
27 views

Question? Creating a website that has 2 sets of intermidate tables

I am creating a web site that uses 6 tables from one database in mysql (example) 2 sets of tables that connect to intermediate tables (using foreign keys to join the tables). 1) Category -> ...