An acronym for "Structured Query Language" (it's not the name of a specific DBMS product), 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 ...

learn more… | top users | synonyms (1)

0
votes
1answer
1k views

Who changed the job schedule on a SQL Server Agent Job (SQL 2000)

Someone (or some unknown process) changed the job schedule on a SQL Server Agent Job on a SQL 2000 database. The original start time was 6:00, but was changed to 4:45; that much I can determine. Is ...
9
votes
2answers
395 views

How many Sproc Parameters is too many?

I've just started writing a Stored Procedure in SQL Server 2008 and have 30+ parameters. I've never written one with more than ~10 parameters, and that got me thinking... At what point are there too ...
0
votes
1answer
3k views

Oracle SQL for left outer join to rownum = 1 of another query?

Background I have a query joining many tables together, the chief of which is a workorder table. I also have a table called WOStatusHistory, which stores every status for every workorder. A diagram ...
6
votes
2answers
1k views

When is a result returned deterministic and when not?

if you execute a statement like this: select first field1, field2 from exampleTable where field1 = '1'; then you get a warning like this: The result returned is non deterministic SQLCode=122 ...
1
vote
1answer
1k views

Heterogeneous queries error using stored procedure

Stored procedure ALTER PROCEDURE Proc_DayShift AS insert into #Punching_History SELECT * FROM SERVER2.MARS.DBO.TABLE1 GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO SET ANSI_WARNINGS OFF ...
0
votes
3answers
888 views

Oracle returns different results when executing a sql with bind variable or with a fix value

The following two statements (strongly simplyfied) returning a different result: with a fix value for rownmun: select * from table where rownum <= 12; with bind variable for rownum: select * ...
4
votes
2answers
972 views

How can I speed up a query that orders by a calculated field?

I will try and give an example - this is not my table structure - I'm simply trying to outline the issue in order to find a solution... Person Id, Name BrothersNames Id, Name SistersNames Id, Name ...
7
votes
1answer
2k views

Unexplained InnoDB timeouts

I've been seeing some very basic updates timing out lately and have not been able to determine the cause. An example: //# Query_time: 51 Lock_time: 0 Rows_sent: 0 Rows_examined: 0 UPDATE photos ...
2
votes
3answers
1k views

SQL Server Max number of Times a table can be referenced as a foreign key?

Is there any maximum on the number of times a single table can be referenced in a SQL Server database via foreign key? IE Table A A_ID Table B ~ B_ID, A_ID Table C ~ C_ID, A_ID Table D ~ D_ID, ...
1
vote
3answers
357 views

How to implement superkey sub key method on cascading tables

If I design a database with a securitymaster table that has all the common columns and then have a final column called securitytype which acts as a reference to the sub table, how is it possible to ...
3
votes
2answers
3k views

SQL Server 2008 T-SQL select hanging, but not dead locked

This is a pretty strange issue so bear with me. I have a stored proc that does some heavy duty processing. When it runs well it usually takes a few minutes depending on server load, but occasionally ...
0
votes
1answer
386 views

Coalesce Function Returning Duplicates

I have a many-to-many relationship setup between three tables. CompanyNotices (M-M) CompanyNoticesLocations (M-M) Locations I would like to retrieve all rows from the CompanyNotices table for ...
1
vote
1answer
495 views

Insert 4 tinyint values into varbinary(4)

I'm working on a function to convert the string representation of an IP into its varbinary(4/16) form. Right now, I have this: @stringIP = '192.168.0.3' select CAST(PARSENAME(@stringIP, 4) as ...
0
votes
0answers
345 views

Oracle Flashback Archive aka Total Recall in MySQL

What would you suggest as a replacement system to achieve the same functionality of Oracle Flashback Archive aka Total Recall in other DBMS, in general or specifically in MySQL or MariaDB? ...
1
vote
3answers
275 views

Is there an equivalent of “OPTION(RECOMPILE)” or “WITH RECOMPILE” for an entire connection?

I'm curious. Is there any way to prevent SQL query execution plans from being cached for an entire connection's duration? Can I run a command that basically says, "use OPTION(RECOMPILE) for all ...
0
votes
1answer
59 views

Oracle: calling udf that modifies the data. How to do it right?

Say I have a function : create or replace function test_function return integer as PRAGMA AUTONOMOUS_TRANSACTION; t_test integer :=1; begin update test1 set id = id+1 ; // table test1 has, for ...
0
votes
1answer
335 views

Returning Multiple Result-Sets or Single XML Blods

I've been writing some new Stored Procedures, and find myself returning between 6-8 result-sets in a few cases. I've always worked under the assumption that there were certain inefficiencies with ...
1
vote
1answer
963 views

Recover PostgreSQL database data

I am using PostgreSQL in my project, Now by mistake I have deleted some records of one of my tables. Now is there any way to recover deleted Records in PostgreSQL?
2
votes
1answer
484 views

high 'total_worker_time' for stored proc using OPENQUERY in SQL Server 2005

I have a stored procedure in SQL Server 2005 (SP2) which contains a single query like the following (simplified for clarity) SELECT * FROM OPENQUERY(MYODBC, 'SELECT * FROM MyTable WHERE Option = ...
1
vote
1answer
581 views

How to implement an effective ACL/auth in a relational db?

We are looking at implementing an ACL that fulfills the following requirements: Most users have access to an item (access to the item by default), but a few is denied access. Most users do not have ...
3
votes
1answer
3k views

Sql. Calculating the size in KB of each row

I'm building now a new sql 2005 database for my company, and we expect this database to be huge with 100's of millions of records. We already know we need to dedicate a separate server with new hard ...
0
votes
3answers
41 views

helping hand for sql server resources

I'm just getting into SQL-SERVER, so forgive me if this is a basic question. I need help, recently work on database programming, For my query development, to understand complex query, to can ...
0
votes
2answers
156 views

MOM and EOM in SQL Server 2005

What is the most sample and practical way to know the MOM (middle of month) and EOM (end of month) in an store procedure on SQL Server 2005? (without doing a select case / switch) EOM is the last day ...
4
votes
2answers
1k views

Query execution showing error as login failed

I want to retrive the table values from other server Query EXEC sp_addlinkedserver @server = 'OPSERVER', @srvproduct = 'SQL Server' EXEC sp_addlinkedsrvlogin @rmtsrvname = 'OPSERVER', @rmtuser = ...
2
votes
2answers
1k views

Update column by comparing date and string values together

I have problem in updating table. I need to update table by comparing date and name with another table. I have two tables: table 1 : dim_sesid name(varchar) role ...
1
vote
1answer
128 views

Is it possible to allow write-through computed columns for legacy code that expects a column to be read/write?

I have this existing table for IP storage: CREATE TABLE [dbo].[IPAddresses]( [ID] [int] IDENTITY(1,1) NOT NULL, [IPv4Address] [varchar](15) NULL, [IPv6Address] [varchar](45) NULL, ...
2
votes
1answer
1k views

Found important issue with SQL Server 2008 R2. Need Advice

Recently while installing my copy of SQL Server 2008 R2; the power went OFF. So now it does say the some features are installed and some are not but when I run SQL server detection manager it says ...
3
votes
2answers
3k views

MySql: Delete all rows greater than n entries ordered by datetime

Can someone help me with a MySql query to delete all rows greater than n entries ordered by date? I.e. say I have 1200 rows of data with a timestamp column. I need to order it by date and preserve ...
1
vote
2answers
6k views

Exporting table records to an INSERT script

I'm setting up a test environment for development and need to export some static data from tables in Production. Ideally the exported product would take the form of a script with all the required ...
13
votes
5answers
711 views

Needing A Database Design Book

I am designing a database and it has so many relationships among my tables and i need a book that teaches database design very well.I am looking for a book where table relationships simple and complex ...
0
votes
1answer
305 views

Implementing Pub/Sub initiated from the database

I have a number of state-full Windows Services that currently poll the database looking for new or changed records in specific Tables and/or Views. For obvious reasons this limits scalability and is ...
1
vote
2answers
9k views

How to join two table and show one query result in MySQL?

I have a table1 (records 3), and table2 (records 3). Where i have field name in both. Now i want to make a result from those two table, which will show me both table records and take only one if there ...
1
vote
1answer
888 views

How do you monitor specific SQL statement of a specific user ?

We have a few standalone users here which cause high server loads for several 11.1.0.7 Oracle's. I spoke with them a few times but it seems that their queries are causing high loads and probably ...
2
votes
1answer
610 views

Oracle 11g production database copy to USB drive

What is the correct commands for backing up a production Oracle 11g database (while still running) to an external USB drive or different directory. I am new to Oracle and but have experience with SQL ...
4
votes
1answer
1k views

How to use the METHOD_OPT parameter in DBMS_STATS.gather_table_stats

Hi there I was just wondering what would be the difference between these 2 METHOD_OPT parameter settings: FOR COLUMNS SIZE 5 some_column and FOR COLUMNS some_column SIZE 5 both will create a ...
1
vote
1answer
442 views

IS_SRVROLEMEMBER returning NULL for valid non windows user

I have a service that executes a stored procedure to query the db for results. The stored procedure needs to use impersonation on the user who is logged in the client (since the service has its own ...
3
votes
4answers
1k views

tempdb in sql server

Using SQL Server 2000, I am getting the following error. The log file for database 'tempdb' is full. Back up the transaction log for the database to free up some log space." How to solve it? I ...
0
votes
2answers
1k views

How can I truly DELETE data from a SQL Server table - still shows up in notepad in backup file?

SQL Server DELETE only marks as DELETED though leaves as data in the data pages. Data pages are 1024 KB in size and this problem can be eliminated by adding a FILLFACTOR that ensures only 1 record ...
4
votes
1answer
297 views

Query Execution Time

I am querying a SQL server 2008 database table having more than 500 million records. The query I fired to move around 10 million records to temp table took 9 hours. Similar query I fired which has ...
0
votes
2answers
3k views

SQL Server 2008 DBCC Problems

We have a database Ms DBCC CHECKDB (MS) Or ALTER DATABASE MS SET SINGLE_USER DBCC CHECKDB(MS,REPAIR_ALLOW_DATA_LOSS) ALTER DATABASE MS SET MULTI_USER Error message Msg 0, Level 11, State 0, ...
2
votes
1answer
2k views

Sql Server 2008 R2 DBCC SHRINKFILE Severe Error

I am trying to run the following command in Sql Server 2008 R2: DBCC SHRINKFILE('filename') When I try to run this command, I get the following error: Msg 0, Level 11, State 0, Line 0 A severe ...
1
vote
1answer
207 views

DB Integrity Check Lock Database

Hi all i'm using The Integrity Check script from http://ola.hallengren.com to check through my database of roughly 65 million records. I was just wondering if this will lock my database? In terms of ...
0
votes
2answers
585 views

does DBCC ShrinkDatabase do a Reorganize of files?

does DBCC ShrinkDatabase doa Reorganize of files? Basically does it mimic the same process as if i checked Reorganize in the GUI?
1
vote
1answer
387 views

Exclude .LOG file while restoring a database

I have a database backup file (MyDatabase.bak). When restoring the database through SSMS it gives me "Not enough space on disk" message. I looked for an option to exclude .LOG file from restore but ...
10
votes
1answer
5k views

Order by column should have index or not?

I have added indexes to table which are used for searching result. I am showing results by ASC or DESC order. So that column should have index or not? I have 2 more indexes on that table. How ...
2
votes
2answers
246 views

Sudden reduction in full backup size

I recently repaired a single corrupt page in one of the tables in a 70gb database. I had a backup which included the data contained in the page so I went about using DBCC CHECKDB with ...
1
vote
1answer
156 views

Duplicate record problem

create table #Personel ( Ad varchar(100) ) create table #Masa ( MasaAdi varchar(100) ) insert into #Personel values('deneme1') insert into #Personel values('deneme2') insert into #Personel ...
2
votes
2answers
48 views

Size of the database and table while inserting and deleting in sql server 2005

I have created a table : Table1. Inserted 100 thousand rows and deleted. I did the same around 100 times ( inserting and deleting). Will it cause of increasing the database and table size every time? ...
2
votes
1answer
131 views

strange optimization of query results in phantom value conversions

-- DB collation is German_PhoneBook_BIN CREATE TABLE [dbo].[partition_tbl]( [tbl_name] [varchar](255) NOT NULL, ) ON [PRIMARY] INSERT INTO partition_tbl VALUES ('some_table_{num}') INSERT INTO ...
7
votes
3answers
1k views

Oracle's left join and where clauses errors

CREATE TABLE "ATABLE1" ( "COLUMN1" VARCHAR2(20 BYTE), "COLUMN2" VARCHAR2(20 BYTE) ); CREATE TABLE "ATABLE2" ( "COLUMN1" VARCHAR2(20 BYTE), "COLUMN2" VARCHAR2(20 BYTE) ); ...