sql

Does varchar result in performance hit due to data fragmentation?

How are varchar columns handled internally by a database engine? For a column defined as char(100), the DBMS allocates 100 contiguous bytes on the disk. However for a column defined as varchar(100), that presumably isn't the case, since the whole point of varchar is to not allocate any more space than required to store the actual data va...

In Oracle, how do I make an external table that has the exact same structure as an existing table?

I know that you can create a table for export like this: create table bulk_mbr organization external( type ORACLE_DATAPUMP default directory jason_home location ('mbr.dat')) as SELECT * FROM mbr; But I'd like to do something like this for imports so I can create an external import table with the same structure as an existing table,...

mysql execution time

Is there a way to get the execution time of the last executed query in mysql? ...

SQL Reporting - Putting Page Count on a non-header level

SQL Reporting 2008 disallows me to put the PageNumber and TotalPages (global) variables on the data level; only allows them in the page header & footer. But their values go hand-in-hand with data. So is there any way of knowing the page number on a non-header level? ...

Invalid object name '@ImageIDsToDelete'

What is wrong with the following ? DECLARE @ImageIDsToDelete TABLE ( xID INT, ImageID NVARCHAR(500)) INSERT INTO [@ImageIDsToDelete] (xID, ImageID) SELECT 1,'x' ...

Database Storage of Formulas with Variables

This is a little complicated, so bear with me. My employer is asking to build a system that calculates task iterations from a set of variables. Each task in a project has a specific formula used to calculate the number of times the task needs to be accomplished ("iterations"). The formula could rely on constants, variables (number-ent...

DataTable Update Problem

Hello, What is the best method for saving thousands of rows and after doing something, updating them. Currently, I use a datatable, filling it, when done inserting by MyDataAdapter.Update(MyDataTable) After doing some change on MyDataTable, I again use MyDataAdapter.Update(MyDataTable) method. Edit: I am sorry for not providing m...

ORA-22054 Underflow Error

I am trying to get my stored procedure working in Oracle and am getting an Underflow error. I am trying to delete related information from six different tables. I can run the delete statements separately in SQL Developer without error. When I try and run the procedure from my C# codebehind I get an exception returned with the Underflo...

Recommendations for free SQL CBT's

Are there any good sites, free preferably, that offer introductory to intermediate learning for SQL skills, either generic SQL, or MSSQL? If seen some good ones on Microsoft's site, www.asp.net, but they head down the development path pretty quickly. For paid solutions, is CBTNuggets worth the money? ...

Linq To Sql Associations

So I've created a dbml in my project, which has three tables: Elements, ElementImages and Images. Every Element record could have multiple ElementImage records and each of those ElementImage records should have one Image record. The primary and foreign keys are all set up correctly and the associations are defined correctly as well. ...

Group Similar records Sql Server 2008

Hi All, I will be writing a query to achieve something like below, please help me TableName: Application AppId (PK,int) AppType (bit) 1 0 2 0 3 0 4 0 5 1 6 0 7 0 8 0 9 1 10 1 11 0 12...

Unexpected empty query results

Ok, This is a dumb one . . . . Select * from <table> where <col1> is null and <col2> = 1; <col1> is varchar2(5byte) no defalut value <col2> is number default of -1 Why will my above query not return any records. I know for a fact that the query SHOULD return a result set, but I'm getting nothing. If I do: Select * from <table> wher...

compare/merge two ms access databases

I've got two ms access .mdb files that I need to compare/merge. Any good tools out there for this? Any way to easily export both to ascii sql where I can use something like Beyond Compare? ...

Maintaining order in MySQL "IN" query

I have the following table DROP TABLE IF EXISTS `test`.`foo`; CREATE TABLE `test`.`foo` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(45) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Then I try to get records based on the primary key SELECT * FROM foo f where f.id IN (2, 3, 1); I th...

What's the easiest way to parse multi-line SQL statements in Java?

I'm pretty new to Java, but I'm looking for Java code that can take multi-line SQL statements, say something like this from a flat file: CREATE OR REPLACE TRIGGER REQ.TR_INPT_STAY_DETAI_SQ_BI BEFORE INSERT ON REQ.INPT_STAY_DETAIL FOR EACH ROW BEGIN SELECT REQ.SQ_INPT_DETAIL.nextval INTO :new.INPT_STAY_DETAIL_PID from DUAL; END; ...

SPROC to arrange results alphabetically, except top two results?

I've got a UNIONed query which returns: ReceiptFolderID FolderParentID FolderTypeID FolderType FolderName FolderDescription ReceiptCount --------------- -------------- ------------ --------------------------------------------...

Cast collation of nvarchar variables in t-sql

I need to change the collation of an nvarchar variable. By documentation: (...) 3. The COLLATE clause can be specified at several levels. These include the following: Casting the collation of an expression. You can use the COLLATE clause to apply a character expression to a certain collation. Character literals a...

SQL: "Write Protect" row of data possible?

May be a stupid questions but can I protect a row of data in a SQL Server database from being deleted or updated without setting user permissions? This is for a default row of data that can be referenced for its default values? Thanks ...

PHP, MySQL: Duplicate series of rows, but change 1 column?

I have a table called scheduler_sched which has several columns, including a column called schedule_id. I need a function where I can pass 2 ids (copy_from_id, copy_to_id) as parameters. And what I need to do is take every row where schedule_id = copy_from_id AND duplicate it but change the copy_from_id to the copy_to_id So basically ...

Is BIGINT(8) the largest integer mysql can store?

I've got some numbers that is now larger than INT can handle. This is a bit embarassing, but I honestly don't know exactly what the BIGINT(8) means. Is the 8 in that the max bit value or the max length? So BIGINT(1) can only be one digit? Or is BIGINT(1) something else? I think tinyint(1) max is 127, how does that work out? What is th...