sql

Getting the Whole Time

How can I get the whole time like this datediff(time, logindate, logoutdate) I know this built-in function doesn't accept time argument but how can I get the whole time rather than minute, millisecond, second etc. ? logindate datetime2 logoutdate datetime2 I want something like 1:05:45 rather than portion of it. ...

SQL constraint minvalue / maxvalue?

Is there a way to set a SQL constraint for a numeric field that min value should be 1234 and max value should be 4523? ...

SQL : Optimizing query to have few IO operations

How can i rewrite the below query to return results with few IO operation and less response time select *, (select Product_Name from InventoryMaster J2 where J1.ParentItem=J2.ItemId) as ParentName, (select Description from InventoryMaster J2 where J1.ParentItem=J2.ItemId) as ParentDesc from InventoryMaster J1 where Flag...

variable column

I have a database in MS-Access which has field names as "1", "2", "3", ... "10". I want to select column 1 then when I click a button, column 2, column 3, ... and so on. How to do that? Actually i want to make a project in JSP. ...

check on overlapping dates (vb.net)

Hi in a program I'm writing I'm creating some objects with a start date (with a datepicker) and an end date (also with a datepicker). Now I need to check if this object's date range overlaps with any other object's date range stored in the database. If it does I can't save it in the database but if it doesn't I can. Anyone has an idea...

Dependency Inject Sql Connection?

Firstly, I'm starting to use StructureMap, but an example in any DI framework will do. I have a class as so, public class GeoData { public List<Country> GetCountries() { IDbConnection con = new SqlConnection(ConfigurationManager.ConnectionString["GeoDataConnection"]) //Sql stuff to return countries from a database...

case consrtuct of sql in asp.net

I want to use case construct of SQL: CASE WHEN ans='A' THEN 1 ELSE 0 END (Where ans is a string declared in ASP.NET) in an insert query like: SqlCommand AnsCmd = new SqlCommand("insert into answers(ans_desc,istrue)values('" + ans1_desc + "',CASE WHEN ans='A' THEN 1 ELSE 0 END)", conn); But it is not working... maybe the syntax is ...

Is there a limit to MySQL queries?

I am trying to insert 10,000+ fields into my database? Is there a limit? $sql = 'INSERT INTO `_'.$test.'` (`user`, `pass`) VALUES ' . preg_replace($test, $replace, $final_check) . ';'; mysql_query($sql) or die(mysql_error()); Every time I try to insert the data, it fails. ...

How to select records from SQL DB that contain the same ID as a .NET datatable records

I'm loading a CSV file containing many thousands of rows into a .NET DataTable that looks something like this: MyLocalDataTable SequenceNo, Etc I have a table in an SQL database and I'd like to pull records into another datatable based on what I find in the CSV file. MySQLBDTable IdentityID, SequenceNo, Etc The SequenceNo is my...

How to refresh the definition of a T-SQL user-defined function after a dependent object is redefined?

Consider the following sequence of events: A view v_Foo is defined A user-defined function GetFoo() is defined that includes all columns from v_Foo (using 'Select * ...') The definition of v_Foo changes and now includes more columns I now want GetFoo() to include the new columns in v_Foo, but it still references the old definition I ...

some php help in making an 'approve form' page...

I have a main form with a lot of inputs. The forms action is set to a php file. After submitted the php-page shows up with all the inputs that the user typed into the form. The user has to re-check everything and hit an 'approve' button! The problem is, I don't know how to do this... I want to eventually put all data into a MySQL databa...

How to speed up SQL query with group by statement + max function?

I have a table with millions of rows, and I need to do LOTS of queries which look something like: select max(date_field) where varchar_field1 = 'something' group by varchar_field2; My questions are: Is there a way to create an index to help with this query? What (other) options do I have to enhance performance of this query? ...

possible to create a form using php code like this?

Is this right, because nothing happens when I hit the submit button: <HTML> <BODY> <?php $ok_button="<input type='submit' OnClick='document.forms['myForm'].submit();' value='approve!';" echo $ok_button; $form="<form name='myForm' action='myPhp.php'><input type='hidden' name='firstname' value='<?php echo $firstname;?>'></form>;" ?> !!!A...

‘QSqlDatabase’ was not declared

Hi, I am very new to using QT4. I am trying to use sql in an already working application. However, when I try to compile I get this error: "‘QSqlDatabase’ was not declared in this scope." Here is the relevent code: #include <QtSql> QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("bigblue"); db.setDatabaseName...

sql problem adding index column to table with data

I am a NOVICE SQL ADMIN... I am trying to add a column 'ID' as Identity Primary Key Index to a Table with 212K rows Tickers Table = (date, open, high, low, close, volume, tickers). When I issue this statement... ALTER TABLE TICKERS ADD ID INT IDENTITY NOT NULL I Get this message... The transaction log for database 'TRADE' is full. To...

Using Aggregate Functions Inside a Trigger In MySQL

I have a 'People' table with several attributes including 'age'. Each time I insert a new tuple into this table, I would like to find out the average age of all the people listed in the table. If the average is above 50, I want to modify the age in the tuple being inserted. I'm using a 'BEFORE INSERT' trigger for this. Here is the test c...

Is there a size limit for the SQL text in a PeopleSoft App Engine SQL Step/Action?

I'm getting the following error: AeSymResolveStatement [775] ... Meta-SQL error at or near position 34338 in statement (108,512). The SQL statement itself is over 40,000 chars long, hence the question. The DB is oracle. Running on Tools 8.49.24. ...

Could you do a query with subqueries like this with nhibernate?

If you had a query that looks like this, could it be converted into a nhibernate query? SELECT .... FROM ( SELECT ... FROM ... GROUP BY... ORDER BY ... UNION SELECT .. FROM ... ) AS ASDF GROUP BY ... ORDER BY ... ...

Wordpress Database Output - Remove SQL Injection Escapes

I'm having a problem using $wbdb. When I insert or update data using $wpdb->insert or $wpdb->update, the SQL injection protection actually inserts the \' into the database, and when outputting that information it has the SQL escape with it. (ie: My Value\'s Escaped). I know there's gotta be a way to escape this using a wordpress func...

User-defined ranking / analytic functions in SQL Server 2008

I'm planning a data warehouse migration to SQL Server 2008, and trying to think of ways to replicate the LAG, LEAD, FIRST_VALUE and LAST_VALUE analytic functions from Oracle in SQL Server 2008. They are not included in SQL Server 2008, although the basic machinery for windowed analytic functions is (e.g. ROW_NUMBER, RANK and DENSE_RANK a...