An acronym for "Structured Query Language", 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 access privileges.
1
vote
1answer
16 views
Table restraints to limit value insertions based off of other values in a row
Using SQL Server 2008 R2
Is it possible to limit what values are allowed in a coulumn based off of other values in the row.
Ex:
myTable:
ID, Test_mode, Active
1 , 1 , Null
2 , 0 , 1
...
1
vote
1answer
13 views
MySQL Insert Row With Foreign Key Equal to ID - Circular Reference
In MySQL database I have an events table which has a circular reference to itself with the following columns.
id (PK) | user_id (FK) | event_id (FK) | title
Each new row inserted has a circular ...
0
votes
1answer
17 views
“relation does not exist” trying to import mysql dump into postgres
environment:
ubuntu 10.04
mysql server 5.1.69
postgres 9.2
Here's the sequence of steps:
created a new postgres database, myDatabase
executed this command: mysqldump -u root -p ...
0
votes
2answers
17 views
MySQL : Query WHERE clause and JOIN
I'm having an issue using a WHERE clause and JOIN.
SELECT * FROM `CallDetailRecord` WHERE `StartTime` >=1357102799000 AND `StartTime` <=1357880399000 JOIN `CallEvent` ON `EventID` = ...
0
votes
2answers
17 views
copy package from schema B to schema C
I am in the next situation: I am using oracle 11g. I am connected to an user, lets say schema1, where are a lot of permissions. I want to create a script which will copy the Package1 (and its body) ...
4
votes
1answer
79 views
CTE memory space
How do CTE memory space work? When you have complex SQL statements executing with the CTE and you get unusually large result set, can it increase the logical reads of the query?
I have a CTE that is ...
0
votes
1answer
48 views
Single quote issue
I have to update a column where I am giving query which is
Update Table
Set col = '[189] IS NOT NULL and [189] <> '''
Where colid= 198
But it's giving output:- [189] IS NOT NULL and ...
0
votes
2answers
52 views
Use an Alias in Where Clause Subquery in Oracle
I need to show some fields from another table in Oracle. Here is my query:
SELECT
ANGGARAN.SIMPEG_PEGAWAI.ID_PEGAWAI AS KODE,
ANGGARAN.SIMPEG_PEGAWAI.NAMA,
ANGGARAN.SIMPEG_PEGAWAI.NIP,
...
-1
votes
1answer
20 views
checking a folder whether required file is present at a regular interval [closed]
i have 4 folder hierarchy in a following format :
Hourly Daily Weekly Monthly.
In every folder i have files which is coming in a frequency based on their folder's name.
Now , i have ...
0
votes
2answers
47 views
Running the following query within a scheduled job
I am looking at running the following query within a scheduled job weekly:
Select TOP 10
s.database_name,
m.physical_device_name,
CAST(DATEDIFF(second, ...
0
votes
1answer
22 views
String replace using concatenated strings from various fields in PostgreSQL
I'd like to remove a substring in a column via update statement. The substring to replace consists of multiple strings from other different columns but in strict order.
The specification says:
...
0
votes
4answers
31 views
Are all matching indexes (indices) searched for a query?
If I have multiple indexes that include a common attribute - will each index be searched upon a query involving this attribute? Or is only one index searched?
-1
votes
1answer
47 views
populate table header and data in another table column [closed]
I have 2 tables: Departments and Employees, where Department_Id is primary key in the departments table and a foreign key in Employees table.
Departments Table:
Department_Id Department_Name
10 ...
0
votes
2answers
15 views
Partitioning MySQL for “expired” transactions to improve performance
I am dealing with an existing application that uses the database as a sort of transaction log in several cases, for example orders or payments. These tables are large (20 - 60 million rows) and poorly ...
1
vote
1answer
31 views
Mysql: Schema/Query Performance Approach for aggregated mailbox folders
I am about to code a messaging system where users can write messages to other users. User can create custom inbox folders for sorting the messages they receive, however, every user has 2 main inboxes: ...
-2
votes
3answers
58 views
Left Join not giving desired result
I have two Datasets
FEES PAYMENTS
CrsCode InstNo FEE Regno CRSCODE Instno Payment
CA1 -2 100 R1 CA1 -2 100
CA1 -1 200 ...
-1
votes
0answers
28 views
Using If statements in stored procedure breaks it [migrated]
This is my stored procedure:
USE [Hires_new]
GO
/****** Object: StoredProcedure [dbo].[ps_selectNewHireWorkPeriodsSQL] Script Date: 05/14/2013 12:59:28 ******/
SET ANSI_NULLS ON
GO
SET ...
-1
votes
1answer
25 views
Why do i get this error…“directory lookup for the file .mdf failed with the operating system error 3” from a log shipping configuration
I have configured log shipping for all our SharePoint 2010. All worked well since Friday and today Monday I ran this query
SELECT *
FROM [msdb].[dbo].[sysjobhistory]
WHERE [message] like '%Operating ...
0
votes
0answers
20 views
How to merge a select statement with a calculated value as new columns? [migrated]
In my sql server code, I have this select statement
select distinct
a.HireLastName,
a.HireFirstName,
a.HireID,
a.Position_ID,
a.BarNumber,
a.Archived,
...
0
votes
0answers
40 views
How to loop through a select statement? [migrated]
I have this select statement
declare @t table (Percentage float)
DECLARE @acc INT
SET @acc = 1
DECLARE @max INT
select @max = max(HireID) from NewHire
WHILE (@acc <= @max)
BEGIN
IF ...
2
votes
2answers
30 views
DB2 will not INSERT into Created Temp Table that I created
I normally use SQL Server but for this project I'm having to learn DB2. If I can get the below code to work I'm set for the whole project. Below is a elementary example of what I cannot get to work. ...
-1
votes
2answers
51 views
How to do division from select statements in sql server?
I am trying to create a select statement that can return a table of 1 column.
Basically, I am looping through all the records of NewHire, and then using its id, to select stuff from another table. I ...
2
votes
1answer
57 views
Reorganize full text catalog is offline or online?
I need to schedule a Full Text Search Maintenance and I was reading this link: http://msdn.microsoft.com/en-us/library/ms176095.aspx. Reading this documentation I am supposing that I need to ...
3
votes
3answers
83 views
Fixed length text file insert into SQL table
I am not a DBA on this one and I will not have access to BCP or anything like that. So I'm wondering if there is still a way to do it in SQL keeping it very basic.
I have 100's of text files that ...
0
votes
1answer
57 views
Validate each parent intermediary is also a parent to itself
I have a table for which I want to validate where each parent intermediary is also a parent to itself. How to write query to validate this?
COLUMN DATATYPE DESCRIPTION
...
-1
votes
1answer
55 views
How to merge data from 2 databases [duplicate]
I have a SQL-Server database that crashed while I was away on vacation. All info from 5/2/13 is missing from our current database because my replacement implemented a back-up of the database from ...
3
votes
1answer
39 views
Scheduled stored procedure on all databases in my server
On SQL Server 2012 (not express edition) I'd like to schedule the execution of a stored procedure every hour.
On the same server I have lot of databases with the same structure, and I'm constantly ...
0
votes
0answers
20 views
developing procedure in sql for global use
what type of complex procedure can i develop in SQL which will make others work easy as well ,
like in Java , i had developed a program for FTP so that anyone can import this program and can use it ...
0
votes
0answers
24 views
Abot SQL Server's Tabular
Goal:
The goal is to view if SQL server 2012 tabular and its in-memory ability with can be used in relation to PowerView, Excel and Reporting service at the same time. No different instance shall be ...
0
votes
1answer
22 views
PostgreSQL created a PostgreSQL user on mac. Is this necessary?
I just installed PostgreSQL on a Mac (Mountain Lion) today.
The installer created a mac user PostgreSQL on my machine. After installation, the user still exists.
My question is that why postgreSQL ...
0
votes
0answers
67 views
how to find similar word with more similarities
how to Find words with length less than or equal....
declare @inp nvarchar(max),@data nvarchar(max)
set @inp='You can dance, you can jive, having .... jove... jve, ...'
set @data = 'jeve'
...
4
votes
1answer
28 views
How to view the full, flattened query underlying a Postgresql view?
If I have a view on a view on a view (etc.), is there a way to show the full query that this expands/flattens to?
0
votes
1answer
21 views
createdb command error in postgres sql
I am using the following command for creating database in postgresql.
createdb -D pg_default -E UTF8 -h localhost -p 5432 -U pramil -W pramil mydb
but this command results prompt for password.When ...
0
votes
3answers
75 views
How to find all positions of a string within another string
How can I find all the positions with patindex in a table or variable?
declare @name nvarchar(max)
set @name ='ali reza dar yek shabe barani ba yek '
+ 'dokhtare khoshkel be disco raft va ali ...
0
votes
2answers
37 views
Using a keywords table with multiple other tables
Using MySQL
I need help determining how to model a Keywords table to three different tables (Products, Certifications, and Exams) - I have included my model which is using what I refer to as ...
0
votes
1answer
31 views
Get Maximum Value
I am using MS Access database. I have a table (Proposal) with the following properties:
ProposalID - PK, Title, RequestedAmount, ResearcherID - FK
I want to run an SQL query to get the candidate that ...
0
votes
1answer
44 views
Query that ranks students order by marks and give the position of student even when there are students with equal marks
I need an sql that will rank students order by marks scored in a specific examtyp e.g CAT1 and give exact position even if the students have equal marks e.g in this sample data admNo 2525 and admNo ...
-2
votes
2answers
61 views
Export complete database to a remote server including (Tables, Stored Procedures, Triggers)
How do we "export" a complete Microsoft SQL server database from one server to a "remote" server (including all the "stored procedures" and "triggers"). The export facility provided in the management ...
1
vote
2answers
70 views
Saving a SQL Server database to a file and opening it on another server under any database name
I am trying to find an efficient way of being able to physically save and open a SQL Server database like how it's done with Access. I would like to be able to save my entire database into a file ...
1
vote
2answers
62 views
How to backup databases to ensure data recovery
I have 15 customer databases that have minimum replication at different sites. I currently do nightly back-ups and transfer the database back-up nightly to our main server via 7zip. We recently had ...
-4
votes
1answer
40 views
Update date Column values? any please help? [closed]
I Want to copy and data in same Table and Update date Column values? any please help?
1
vote
1answer
31 views
weak entity with a many to many relationship with its owner
I have a database that keeps track of the hours worked by a contractor per week. I have one table for contractors that contains "con ID" as primary key. The other table Weekly Hours Tracker contains ...
1
vote
2answers
47 views
Is it possible to validate DML statements?
Suppose that I want to delete a user named 'abc cba' from the database. So I run the following query:
DELETE FROM table WHERE fname = 'abc' AND last name = 'cba'; commit;
Now, there can be more ...
7
votes
3answers
180 views
Choosing a database for storing large amount of data and allowing for thousands of writes
I am working on a project that has some serious requirements regarding its database and having hard time choosing the best solution. The details are:
Database will easily reach tens of terabytes of ...
1
vote
1answer
50 views
How do I refresh SQL server cross database references after a database is reattached with a different name? (Are there hidden synonyms?)
I have 2 seperate SQL databases on the same SQL instance. Database1 references tables on Database2 in its views and stored procedures. Everything was working fine until we had to create a fresh ...
-1
votes
1answer
48 views
Why is this mysql query wrong? [closed]
I try to run the following sql query in mysql
SET @rank:=0;
WITH TEMP
(
SELECT @rank := @rank + 1 AS ROW_ID , UUID() as RANDOM_VALUE,D.*
FROM house_information_new D
ORDER BY ...
1
vote
1answer
52 views
Using a Having clause with an outer join
I want to use a "having" clause with an outer join, using a column that is used in the outer join.
This is my query:
SELECT
I.CARD_BIN BIN
FROM
GE_ICA_BIN I
LEFT OUTER JOIN GE_PAYEE_VALIDATION ...
0
votes
0answers
15 views
Range query from month and year [migrated]
I have a table like this:
ID month year content
1 4 2013 xxxxx
2 5 2013 yyyyy
3 6 2013 zzzzz
4 8 2014 fffff
I want to query it based on a year ...
1
vote
3answers
50 views
Transfer data from DB2 to Oracle
I want to transfer data from an old DB2 system to a new Oracle database.
How should I go about doing this?
0
votes
1answer
58 views
Complicated join with where clause
I have four tables:
sales
sales_thumbs
sales_images
sales_sizes
sales table:
+--------------+---------------------+------+-----+---------+----------------+
| Field | Type | ...

