sql

How do I combine two queries (union all) into one row?

I have a tricky situation in trying to get information from multiple queries into a single row. Consider the following table: CpuUage: Time time Group char(10) Subsys char(4) Jobs int Cpu int holding the following data: Time Group Subsys Jobs Cpu ----- ------ ------ ---- --- 00:00 group1 ...

Best Database for Computational Problem

I'm trying to decide what database system to use for storing information that is relatively static but needs to be computed in a number of different (runtime specified) ways. The basic contours of the data are votes in the US Congress: A bill: has many roll calls has a name, and other short metadata has text, and other potentially lon...

sql loader through C#

I am using a sql loader statement and have the Time_Stamp column t be updated in the database. I am using Time_Stamp EXPRESSION "current_timestamp(3)" in the sql loader command but im doin this through C# program. All the other fields are loaded in a csv from where they get loaded. But what do i write in the csv for Time_stamp colu...

Insert Data Into Tables Linked by Foreign Key

Hello all, I am using PostgreSQL. Customer ================== Customer_ID | Name Order ============================== Order_ID | Customer_ID | Price To insert an order, here is what I need to do usually, For example, "John" place "1.34" priced order. (1) Get Customer_ID from Customer table, where name is "John" (2) If there are no ...

Strange constraints in generated SQL

Note: This question is not related to Visual Paradigm. Anyone that knows SQL could answer it. I am using Visual Paradigm to model a database in our project (using ER diagrams). When Visual Paradigm generates the SQL equivalent for the database and I import it in MSSQL it works pretty. I took a look in generated SQL code to make sur...

sql Merge databases.

Hi I have a Databse "Product" in in sql 2008.I have another Databse "ORDER" in sql 2008. Both exist in different servers. Now the requirement is to Merge both databases, and test pointing the applications to this new DB. Can anyone suggest the best way to accomplish this without losing the information? I have 2 options. 1) Script th...

How does ADO.NET store dates and time?

I was lazy and write an insert statement with DateTime.Now. It occur to me later i should have written DateTime.Now.ToUniversalTime(). This got me thinking, does ADO automatically convert dates into universal time? and restore it to local when i pull data out? Or do i need a write ToUniversalTime and ToLocalTime myself in every area of c...

Storing attendance records in the database.

I found a similar question asked previously (School attendance database) I have to deal with these additional conditions. Total number of users recording attendance would be 100,000. Each user will have swipe-in swipe-out entry. A user may do multiple swipe-in swipe-out incase s/he is not sure data was captured. A record of 1 year at...

Problem accessing SQL Server from network share after reinstalling SQL Server

Hello everyone, I have a problem, that is really driving me crazy. First of all I must admit, that most of the work was done by a coworker, who isn't available anymore. Before reinstalling the MSSQL Server rig, the whole thing looked like that: Someone has developed a little .Net c# program which connects to the SQL Server, that is ...

Which one of these queries has a better performance?

I have three tables, with these fields: classes: class_id | name | grade classes_students: class_id | student_id students: student_id | name Classes has a n:m relationship with Students, so one class can have many students, and one student can listen to many classes. I want to select all students of a particular class, where class_...

sql compare datetime today

Hi I hope anyone can translate my abstract query. I want to select * from TABLE where ( [MYDATETIMEROW] < (TODAY - 3 Days)). Does I have to Convert, cast or use datepart or anything else?.. im confused. Are there simple rules? I would'nt have problems to do that with linq but simple sql I learned just hardly. Thank you and best rega...

How do you move a partitioned table from one tablespace to another in Oracle 11g?

I have a partitioned table that belongs to tablespace report. I want to move it to tablespace record instead. One possibility is to drop the table and recreate it in the new tablespace, but that is not an option for me, since there is data in the table that needs to survive the move. I started by checking that the partitions actually b...

Is there an conceptual difference between a so called "record set" and an so called "statement"?

I wonder why the result of an SQL query in PHP PDO is called "statement". I'd expect "record set". My english is pretty bad as I'm not a native speaker. So: I craeate a "query" to "ask the database to do/retrieve something". Sometimes I use "prepared statements" to ask that (blue confusion alert!). Then, PDO returns me an object of clas...

Difference between SQL connection string (local) and .\

Between SQL 2000 and 2005 MS changed the syntax to connect to a local database from (local) to .\instanceName. I have a client who has been using (local)\instanceName to connect to local SQL Server 2005 databases. Usually it works fine, but sometimes it doesn't and he has been using PCname\instanceName. Why does this sometimes fail? ...

Create SQL Server Deployment script using database publishing wizard

I'm getting the following error when using the Database Publishing wizard to script a SQL Server Express database for deployment. I have googled for hours unsuccessfully. Anyone had this isssue or know how to solve it? Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occ...

Query on Sql Joins

I have three tables. tblLink: (LinkId, LinkName, GroupId, ,SubGroupId) GroupId and SubGroupId are foreign key in tblGroup and tblSubGroup tblGroup: (GroupId, GroupName) tblSubGroup: (SubGroupId, SubGroupName) in tblLink SubGroupId is allowed Null but GroupId is Mandatory. I want to fetch LinkName, GroupName, SubGro...

Oracle case sensitive Format SQL

Dears, I need to format SQL statement for Oracle Db. I have a sql statement and I don't want to change the case. For Eg. CREATE TABLE DPAuditTrailDetail ( ID NUMBER (19, 0) DEFAULT 0 NOT NULL, AuditTrail NUMBER (19, 0) DEFAULT 0 NOT NULL, sysObjectField NUMBER (19, 0) DEFAULT 0 NOT NULL, OldValue ...

access to standalone app with more stable database

Hi, Does anyone have experience of rapidly translating an access application into a standalone windows application? My current thoughts are to create an SQL database and a gui in c# and vb, or adobe flex 3. As with acces, the GUI would mainly comprise of controls such as radio buttons, combo box (populated from a table), check boxes, t...

group by price range

Say I have a table of real estate properties: A 15,000 B 50,000 C 100,000 D 25,000 I'd like to group them by 0 - 49,999, 50,000 - 99,999 and 100,000 - 200,000 So the result should be: 0 - 49k (2) 50k - 99k (1) 100k - 200k (1) Is there a way to do that in one SQL statement? I'm using Postgres by the way. ...

create/ alter from SQL stored procedure

hi I want to call create table/ alter table command from a procedure. Is it possible? My requirement is to change the datatype of a column in all tables. So, I am just getting the column name from user_tab_cols. Now I want to create a temp table which requires create statement .. but i am unable to use that within a proc. Can anyon...