sql

LINQ2SQL: orderby note.hasChildren(), name ascending

I have a hierarchical data structure which I'm displaying in a webpage as a treeview. I want to data to be ordered to first show nodes ordered alphabetically which have no children, then under these nodes ordered alphabetically which have children. Currently I'm ordering all nodes in one group, which means nodes with children appear nex...

HTML5 Web Database Security

Should the HTML5 database be used to store any form of private information? Say we have the following scenario; You're browsing a web-mail client, that uses the web database to store mail drafts after you've written some information you close the web browser. What's to stop me from getting access to this information? If the webpage t...

All of a Sudden , Sql Server Timeout

Hey Guys We got a legacy vb.net applicaction that was working for years But all of a sudden it stops working yesterday and gives sql server timeout Most part of application gives time out error , one part for example is below code : command2 = New SqlCommand("select * from Acc order by AccDate,AccNo,AccSeq", SBSConnection2) rea...

Is it possible to output the results of an sql command to a text file, when sent via SMO in C#?

I am using SMO in C# to run an SQL script. I need to output the results of the file into a text file. When using a command line to run the query I can get the desired result using the "-o [output file]" argument. Is there a way to carry out the same operation using an SMO object? At the moment my code simply sends an sql script to a se...

Refining data stored in SQLite - how to join several contacts?

I'm storing contacts between different elements. I want to eliminate elements of certain type and store new contacts of elements which were interconnected by the eliminated element. Problem background Imagine this problem. You have a water molecule which is in contact with other molecules (if the contact is a hydrogen bond, there can b...

OPENROWSET inserts null

Hi, I am using this: insert into bla select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;HDR=YES;Database=c:\bla.xls', 'select * from [Sheet1$]'); but for some reason some values contain null although the original data definately contains values (e.g. 'abc'). What could be the reason for this strange behaviour. Th...

How to use a varying database?

I want to use a database which name is stored in a variable. How do I do this? I first thought this would work but it doesn't: exec('use '+@db) That will not change database context Suggestions anyone? ...

Simple aggregating query very slow in PostgreSql, any way to improve?

HI I have a table which holds files and their types such as CREATE TABLE files ( id SERIAL PRIMARY KEY, name VARCHAR(255), filetype VARCHAR(255), ... ); and another table for holding file properties such as CREATE TABLE properties ( id SERIAL PRIMARY KEY, file_id INTEGER CONS...

Exact match with sql like and the bind

I have a bind in the sql query (select * from users where name like '%?%') the bind set the ? Now, if i want to search with like method everything work but if, without change the sql, i want to search the exact match i dont now how to do. I tried some regexp int the textbox es: _jon \jon\ [jon] and some others but nothing work properly....

Is it possible to alter the cascading behaviour of existing mysql foreign keys?

I have two tables in mysql, both are type InnoDB and there is an existing foreign key from the first to the second. However, the foreign key was created without any cascading behaviour. The table is large, and any changes to indexes or new keys locks the table for ~20 minutes. Is it possible to add "ON DELETE CASCADE" behaviour to an ...

Data Conversion

How do I convert 0.50 to 50 or 0.1429 to 14.29 in sql query? My data type is real. ...

Try..Catch SQL Question

Is there any way of know which of my update or insert statements executed the catch block by failing ...

TableAdaptor's auto-generated method is returing the wrong type.

I have created a table adaptor method that I would like return a int or an ?int or something useful, however, it is returning an object. I created the method in the wizard and chose "SELECT which returns a scalar value" The sql is: SELECT COUNT(*) FROM myTable WHERE (firstID= @firstID) AND (secondID= @secondID) The auto ...

(Oracle) How get total number of results when using a pagination query?

I am using Oracle 10g and the following paradigm to get a page of 15 results as a time (so that when the user is looking at page 2 of a search result, they see records 16-30). select * from ( select rownum rnum, a.* from (my_query) a where rownum <= 30 ) where rnum > 15; Right now I'm having to run a separate SQL statement...

WHERE vs HAVING

Why is it that you need to place columns you create yourself (for example "select 1 as number") after HAVING and not WHERE in MySQL? And are there any downsides instead of doing "WHERE 1" (writing the whole definition instead of a column name) ...

What's the meaning of the GO-statement in TSQL

I'm new to TSQL and wondering what the GO statement really means. To me it just seems thrown in there where ever it seems to fit. I guess it somehow tells sql server to run the previous statement? What happens if you don't use them at all? Could someone give an example where a statement will break if I don't use a GO. Please elaborat...

NULL-keys for key/value table

(Using Oracle) I have a table with key/value pairs like this: create table MESSAGE_INDEX ( KEY VARCHAR2(256) not null, VALUE VARCHAR2(4000) not null, MESSAGE_ID NUMBER not null ) I now want to find all the messages where key = 'someKey' and value is 'val1', 'val2' or 'val3' - OR value is null in...

Need to combine common result of two select statements

i have to select the common coloumns c1 ,c2,c3 from result of two sql satements. 1) select c1, c2, c3,count(c3) from (select * from form_name where data_created >'1273446000' and data_creazione<'1274569200') group by c1,c2, c3 having count(c3)>1 2) select c1, c2, c3,count(c3) from (select * from form_name where data_created>'127...

SQL Server 2000: Why is this query w/ variables so slow vs w/o variables?

I can't figure out why this query would be so slow with variables versus without them. I read some where that I need to enable "Dynamic Parameters" but I cannot find where to do this. DECLARE @BeginDate AS DATETIME ,@EndDate AS DATETIME SELECT @BeginDate = '2010-05-20' ,@EndDate = '2010-05-25' -- Fix date range to...

Access Log in troubles

Lately there has been a problem running some of our reports in access. Last week(the beginning of the week) we tried to run a reports lets call it A and it kept giving us the log in prompt. Even when the correct user-name and password were entered the log in box would just keep reappearing until cancel was pressed. I clicked the debug an...