sql

new_time function in SQL Server 2005

Is there a function or a workaround in SQL Server 2005 that is equivalent to the new_time() function in oracle? ...

tsql- to find when was the database taken offline

Is there a way how we can know when was a database taken offline? Platform: SQL server 2005 ...

SQL View not working with Entity Framework MVC 1.0

I have a SQL View (SQL Server 2008) that contains 4 columns and works just fine in SSMS. I added the SQL View via Database Update to my Entity Framework model. No complaints, but I noticed that EF decided to make 2 of the 4 columns EntityKeys. The problem I'm having is that when I run the query in my app code, I get the right number...

Keeping track of "prices" in a SQLite database?

My Schema looks like this: CREATE TABLE items ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, description TEXT NOT NULL, quantity INTEGER NOT NULL price TEXT NOT NULL, category_id INTEGER NOT NULL ); CREATE INDEX "item_id" ON "items" ("id"); I'm setting price as TEXT but it probably should ...

How to edit SQL Server Primary Database File .mdf

I have a SQL Server Primary Database file. (.mdf) I require a program which can open the file and let me edit some data. Since there are many fields, it tedious to open all the records and modify it. Would it be a good idea to do so? I can always take backup of .mdf file before playing with it, since I do not have any programming know...

How do I construct a cross database query in MySQL?

I've got two databases on the same server. The Google gave me some hints but there wasn't anything "official" that I could find. Could someone point me to the documentation that explains how to do this? An explanation using PHP would be useful as well. Thanks! ...

RDBMS in ms acces

I have two tables: Cartoon containing P_Name,U_Of_Pack,Weight,No_Cart,No_Pack,Tot_weight Product containing P_Name,U_Of_Pack,Weight,No_Cart,No_Pack,Tot_weight When any changes in the Product table are made to No_Cart, No_Pack, Tot_weight columns, these values should be subtracted from the same column's of Cartoon table & the updates ...

Upgrade strategies for bad DB schema designs

I've shown up at a new job and discovered database which is in dire need of some help. There are many many things wrong with it, including No foreign keys...anywhere. They're faked by using ints and managing the relationship in code. Practically every field can be NULL, which isn't really true Naming conventions for tables and column...

Please help me convert a Linq Query to a SQL Query... Desperate...

Hey all, Im pretty proficient in LINQ, but not in SQL. I understand cursors are horrible and shouldn't be used. I know SQL Syntax pretty well, but I am trying to figure out how to convert this query and update to SQL from Linq. I don't know how to go through the Foreach of SQL without using cursors and Im a bit lost on what to do ne...

Slim but long SQL Server 2005 Table

Hi, I have an SQL table with the following structure: Code1 - int Code2 - int Val1 - real Val2 - real Val3 - real There is only one index (clustered) were Code1 is the first indexed column and Code2 is the second. The size of a single record is 20bytes. I need to be able to store around 150,000,000 records and the biggest select ...

SQL Query to return N rows from dual

I want to write a SQL query which accepts a bind variable (say :NUM) and its output consists of one column & :NUM number of rows, each row having its row number. i.e. if we pass :NUM as 7, the output should be: VAL ==== 1 2 3 4 5 6 7 There shouldn't be any actual DB tables in query and no PL/SQL code should be used. i.e. only dual sho...

Building SQL Query

Hi all, I need some help to build SQL Query. I have table having data like: ID Date Value1 Value2 Code 1 12/01/2009 4 3.5 abc 2 12/02/2009 3 4.0 abc 3 11/03/2009 6 8.5 xyz 4 11/01/2009 2 5.5 abc 5 11/02/2009 4 6.0 xyz 6 12/03/2009 5 7.0...

PostGreSql query for equality between two tables

I have two tables A & B and i would like to have a query that : return TRUE ONLY if the two tables are the same (i mean every lines in A are present in B & vice versa, no matter the line order) I have use the keyword EXCEPT but it doesnt work in many cases Thanks for your help. ...

How woud I join this query in one single SQL statement?

Let's say I have these tables, with these fields: companies: company_id | name | num_employees companies_countries: company_id | country_id countries: country_id | country_iso_code Assuming this is a 1:1 relationship: How can I join the country_iso_code directly into the company recordset, when I fetch all the companies? I think I w...

SQL Select aggregate values in column

Hello I'm curious, is this result set can be achieved with sql query? Here is the table item_id name availability ----------------------------------- 1 brush available 2 brush available 3 paint not available 4 paint available here is the result name available ...

MySQL - Nested set model: searching in nodes

Hello. Let's just say I have tree in my table called "page": Foo -- Bar 1 -- Bar 2 -- Bar 3 -- Some foo -- Some value Bar -- Bar 4 I want to search by node's name. For example "bar%". Excpected output should be: Foo -- Bar 1 -- Bar 2 -- Bar 3 Bar -- Bar 4 I can't find solution to write right query in My...

Passing variables to stored procedure with Classic ASP

Ok so I am trying to pass some string variables from a classic ASP page to an MSSQL2000 db thusly: strSQL = "exec UpdateEvent " & xID & ",'" & xEventID & "'," & xEventDisplayName & "," & xEventType & "," & xEventStatus & "," & xStartDate & "," & xEndDate & "," & xSurveyTemplateID & "" Yet I end up with the error (including writing out...

SQL Server CASE WHEN and IN construction

Having a problem with a WHERE search statement would like to use a construction like.. WHERE f.foo IN CASE @bar WHEN 'BAR' THEN ('FOO','BAR',BAZ') WHEN 'BAZ' THEN ('FOOBAR','FOOBAZ') END or WHERE CASE @bar WHEN 'BAR' THEN f.foo IN ('FOO','BAR',BAZ') WHEN 'BAZ' THEN ...

Excel VBA, how to do multiple database entries

I need to populate a database with thousands of entries on a daily basis, but my code at the moment manually inserts each one into the database one at a time. Do While lngSQLLoop < lngCurrentRecord lngSQLLoop = lngSQLLoop + 1 sql = "INSERT INTO db (key1, key2) VALUES ('value1', 'value2');" result = bInsertIntoDatabase(sql, T...

What are the resources or tools used to manage temporal data in key-value stores?

I'm considering using MongoDB or CouchDB on a project that needs to maintain historical records. But I'm not sure how difficult it will be to store historical data in these databases. For example, in his book "Developing Time-Oriented Database Applications in SQL," Richard Snodgrass points out tools for retrieving the state of data as ...