sql

Import database from File PROGRAMMATICALLY?

Hi guys!! Is there a way to programatically import an entire database from a file with SQL?? (either .CSV , .SQL and .DB files are fine) Thanks!! EDITED AFTER TO CLARIFY: I am interested in a solution that is Database independent (has to works with all types of databases (Mysql, SQL Server, PostGres, Oracle...) ...

Generate row numbers in SQL from Interbase

Is this possible from Interbase ? For example like in this link. ...

How do I get a single out from an Oracle-Procedure?

Hey folks, I've got this procedure: CREATE OR REPLACE PROCEDURE CONV1( pDate IN VARCHAR2, pYear OUT number, pMonth OUT number, pDay OUT number ) AS lDate DATE; BEGIN lDate := to_date(pDate, 'DD.MM.YYYY HH24:MI:SS'); pYear := to_number(to_char(lDate, 'YYYY')); pMonth := to_number(to_char(lDate, 'M...

MySQL stored procedure for duplicating records from 4 inter-related tables

I have 3 tables, networks, nodes, networknodes, networkconnections. networknodes has 3 fields network_node_id, network_id, and node_id, the last two are forien key references to network. and a network may include multiple copies of same node (but with diffrent network_node_id) networkconnections has the fileds networkconnection_id, sta...

how to create this as an index view?

SELECT u.Id FROM Users u WHERE FREETEXT((FirstName,Lastname,MiddleName),'') UNION SELECT c.AId FROM Certification c WHERE FREETEXT(*,'') UNION SELECT ad.AId FROM ApplicantDetails ad WHERE FREETEXT(*,'') UNION SELECT eb.AId FROM EducationalBackground eb WHERE FREETEXT(*,'') UNION SELECT ed.AId FROM EmploymentDetails ed WHERE F...

stored procedure return .00 decimal

this stored procedure does not return salary with decimal format 00.00 ALTER PROCEDURE taxable_varsalary @emp_code bigint, @co_id bigint AS declare @t_varsalary decimal(8,2) set @t_varsalary = (select sum(tran_value) from emp_ded_ben_trans where emp_code=@emp_code and co_id=@co_id and period_flg=2 and tax_flg=0) RETURN @t_var...

How do you implement the equivalent of SQL IN() using .net

In .net (c# or vb) expressions, how would you implement SQL's handy IN() functionality? i.e. value in (1, 2, 4, 7) rather than: value = 1 or value = 2 or value = 4 or value = 7 There are obviously many ways, I'm looking for the most clean and simple! ...

List all SQL instances, and their tables

I want to list all SQL server instances and their tables. I have code that lists all the servers correctly but I cannot seem to get a list of their tables. DataTable dataSources = SqlDataSourceEnumerator.Instance.GetDataSources(); foreach (DataRow row in dataSources.Rows) { Console.WriteLine("Server ...

Help converting SQL query to JPQL

I have a SQL query that I need to translate over into JPQL, and I'm beginning to wonder if this is one of the cases where I'll just have to use native SQL. For reference, here is the SQL query. SELECT c.title, a.approval_total, r.requested_total FROM codes c INNER JOIN (SELECT code_id, year, SUM(requested_amount) requestedTotal ...

What is wrong in this SQL Query?

SELECT "D"."Name", "D"."Sname", "D"."Date, "D"."Type", "D"."Place", "D"."Unit1", "D"."Unit2" FROM "Data" AS "D", "Search" AS "S" WHERE "D"."Name" = "S"."Name" AND "D"."Sname" = "S"."Sname" AND "D"."Place" = "S"."Place" ...

How to optimize the response time for following Oracle 10g query?

How to optimize the response time for the following query: SELECT /*+parallel */ cc.customer_id AS customer_id, cc.title1 AS title1, cc.forename1 AS forename1, cc.forename2 AS forename2, cc.surname1 AS surname1, cc.surname2 AS surname2, cc.company_flag AS company_flag,...

SQL in MS-Access: Using COUNT, JOIN and returning 0s

Hi folks, Apologies for posting this but although there are a few examples on the site, I just can't get mine to work. So I have two tables as follows: A Telephony table ID | Name | GradeID 1 Richard 1 2 Allan 1 3 Peter I also have a Grade table: ID | Name 1 1 2 2 3 3 4 4 5 5 Anyway I'm trying to us...

MySQL query for rows at specific time intervals

Hi, I am having some confusion with a mysql query. Any help appreciated. My current query: SELECT r.name , r.network , i.name , d.dtime , d.input FROM router AS r INNER JOIN interface AS i ON r.rid = i.rid INNER JOIN 1273118400_1_60 AS d ON i.id = d.id AND dtime BETWEEN 1273152000 AND 1273153800 WHERE i.status = "active" Now I am ...

Errors with MySQL stored function creation ERROR 1064 & 1327

I am using MySQL v5.1.36 and I am trying to create a stored function using this code. DELIMITER // CREATE FUNCTION `modx`.getSTID (x VARCHAR(255)) RETURNS INT DETERMINISTIC BEGIN DECLARE y INT; SELECT id INTO y FROM `modx`.coverage_state WHERE `coverage_state`.name = x; RETURN y; END// When entered into the...

Synchronizing client-server databases

I'm looking for some general strategies for synchronizing data on a central server with client applications that are not always online. In my particular case, I have an android phone application with an sqlite database and a PHP web application with a MySQL database. Users will be able to add and edit information on the phone applicat...

How to enforce NOT NULL in a view's computed column

Dear Colleagues, I want to alter a view as follows: ALTER VIEW [dbo].[ViewOne] as SELECT columnOne, -- not null columnTwo, --not null (convert(decimal(2,0), columnOne)) as columnThree -- I want this not to be NULL FROM DBOne.TableOne Since columnOne is "not null" I want to force columnThree to be "not null" also. Is...

Change syntax using regular expression

I have some inherited legacy language code snippets stored in a database table that I need to transform to a SQL like syntax so it can be used more effectively. For example, one of the snippets is of the form keyword = [a,b,c,x:y,d,e,f,p:q] to indicate either discrete comma separate values or a range of colon-delimited values How c...

How can I write a SQL statement to update a column in a table from another column in the same table?

I have an oracle DB where a program is writing into two columns when it updates the table. The 2nd column is based on the value from the 1st column. Well over time people have hand edited the database and forgot to insert values into the 2nd column. I'd like to write a simple sql statement that updates all columns and syncs the 2nd co...

Extract directory from Files field in SQLite table

I have a SQLite table with a field named FullFilename. Now, I want to select the rows of files in a certain folder. Let's say the table contains: c:\folder\file1.jpg c:\folder\file2.jpg c:\folder\subfolder\file1.jpg c:\anotherfolder\file1.jpg And I want to select only the rows with files in "c:\folder\". Not in a subfolder "c:\folder\...

Mysql Query Confusion

Hi, I have these tables: domain domain_module domain_module_feature domain_module_feature_to_domain A domain can have many domain_module_feature(s), the domain_module_feature_to_domain table contains 3 columns - dmf_id, dmf_domain_id and dmf_feature_id. For ease of this example lets assume domain has just 2 columns - dm_id and dm_na...