sql

How to fix error in exporting Excel data to SQL Server database?

Cannot insert the value null into column 'COLUMN1',table'DB1.dbo.table1';Column does not allow nulls. Insert fails.the statement has been terminated. This always shows if edit or save another data onto excel columns. using (SqlCommand cmd = new SqlCommand("Insert into dbo.Table1 Select * FROM OPENROWSET('Microsoft.Jet.OLED...

MySQL IF conditions and internationalization

Hello, I'm wondering the following, the query below will select the appropriate fields if a language is set. First question, I need the fields, title, keywords and description from the pages table or, if the language matches and the field is not null the page_langs table. Now I do this with three IF statements, is it possible to do this...

SQL 2000 Set Query

Hi, I have a SQL 2000 server with a database (ITinventory) and a table which is also called ITinventory. I would like to create a query which will look at the field 'Status', if the status is 'disposed' then I would like to set a 'location' field to 'disposed'. Many thanks ...

Unit test problem with DataSource attribute [C#]

Hi, I try make my first simpel Data Driven Test. I created db (UnitTestsDb) with MS SQL Managmet studio, and also I created one db table (UsersTab). I try use this db in unit test. Code is here: [TestMethod()] [TestProperty("TestCategory","Developer"), DataSource("System.Data.SqlClient", "Data Source=.\\SQLEXPRESS;AttachDbFilena...

How can I find duplicate consecutive values in this table?

Say I have a table which I query like so: select date, value from mytable order by date and this gives me results: date value 02/26/2009 14:03:39 1 02/26/2009 14:10:52 2 (a) 02/26/2009 14:27:49 2 (b) 02/26/2009 14:34:33 3 02/26/2009 14:48:29 2 (c) 02/26/2009 14:55:...

Sql Server 2005 - Add partition scheme to a non partitioned table

I have a table that has more than 50 million records and which does not have any partition. But now i want to add a partition scheme to this table. This table has a primary key. But i want to partition it using another int column. How can i do it? ...

Perform single SQL query over internet Android

Hi everyone, I am trying to find a way to goto a database located on the web perform 1 query and close the connection. I have not had any luck with finding an answer, and I really don't know how to solve this. Internet connection is not an issue, nor is any security issues. Also this cannot be solved with an internal database and this ...

unexpected result from SQL - CASE statement returns value other than stated.

Hi, Can anyone help me explain why the changed line below returns a 0 instead of the requested 11 or 12? I'm using MySQL, and this query otherwise runs, correctly... I'm attempting to catch the difference between a 0 and a null in the said field. SELECT SUM(CASE WHEN pr.heatEventID=1 THEN pr.points+1 ELSE '-' END) AS `100m` , SUM(...

SQL: Is it possible to 'group by' according to 'like' function's results?

Hello, I am using Oracle SQL and I want to group some different rows that 'like' function results. To elaborate with an example: Let's assume I have a table MESA with one of the columns is a huge string. And I am counting the number of rows matching particular patterns: SELECT m.str, count(*) FROM MESA m WHERE m.str LIKE '%FRUIT%' A...

Problem with cast convert and view all in TSQL

Dear Board, I have a view called vw_FormatTable1 which contains Convert( CHAR ( <SIZE> ), Coalesce (Convert (VarChar, [<FIELD>],120),'')) AS [<FIELD>] where <SIZE> is the width of the field to be output and <FIELD> is the field name And this basic block is repeated for all approx 600 fields in my base table creating a view of over 5...

Retreive all Children and their Children, recursive SQL

Consider the following rows in a database: Id | Parent __________________ 1 null 2 1 3 2 4 3 5 null 6 5 Each Id that has a null Parent is the "Owner"/"Super Parent". What would be the best approach, performance wise, to collect the parents and their children ? Shoul...

Select from dynamic table names

Hello pals, So here's the problem statement, SELECT app_label || '_' || model as name from django_content_type where id = 12; name ------------------- merc_benz DJango people might have guessed, 'merc_benz' is a table name in same db. I am writing some complex SQL migrations and I need to select result from such dyn...

SQL: have a CTE be just literals

This is in teradata. For many good reasons, I would like to have a something like the below, where I start by making a CTE that just has a list of literals, and then can refer to it in later statements: with MyList(num) as( 'a','b','c','d' ) select foo from mytable where x in ( select(num) from MyList)) This is a very contrived ...

Excluding duplicate items from a query using 'group by'

I have three tables: table 'received' ------------------ partner_id int item_id int table 'delivered' ------------------ item_id int delivery_date date customer_id int table 'partners' ------------------ id int name text table 'customers' ------------------ id int name text What I'd like to query is which items have been delivered ...

perl, dbi with sql statement with a like condition

hi all, in my code i must do a simple sql query with a like condition. i've do in this way my $out = "/Users/zero/out.log"; my $filename = "/Users/zero/data.txt"; my $dbh = DBI->connect("DBI:Oracle:sid=$sid;host=$host;port=$port", $user, $pwd) or die "Couldn't connect to database: " . DBI->errstr; my $query = "select SOMETHING from SO...

XSLT transform creates StackoverflowException

I tried to perform XSLT transform of a XSD file. My goal is in the end to create SQL from XSD. So far so good, this is what I have: void Convert() { XPathDocument xpathDoc = new XPathDocument(@"myschema.xsd"); string xslPath = @"convert.xsl"; XslCompiledTransform transform = new XslCompiledTransform()...

convert any date string to timestamp without timezone

I'm getting xml and rss feeds and putting the data into a database. I've run into two different date formats so far... Wed, 21 Jul 2010 00:28:50 GMT And 2010-07-20T17:33:19Z I'm sure there will be more. My postgresql database for the date is timestamp without time zone. Is there an existing function in php or is there a procedure t...

Cisco CallManager data location question - Manager ID

I'm trying to find where, in the Call Manager database the Manager ID is stored? From a front-end perspective, I see that it's entered in the User Configuration screen, which has the user's first & last name, ID, PIN, and Telephone number; the last field is the Manager User ID. Please let me know if you can provide any help, thanks! ...

How to select rows based on unique column

Hi, I have table with values as ColumnA ColumnB ASD A CSD B DSD C ESD D FSD D GSD D Column A is primary key, I need result as ColumnA ColumnB ASD A CSD B DSD C ESD D I want all unique values from column B & their a...

How can I get dict from sqlite query?

db = sqlite.connect("test.sqlite") res = db.execute("select * from table") With iteration I get lists coresponding to the rows. for row in res: print row I can get name of the columns col_name_list = [tuple[0] for tuple in res.description] But is there some function or setting to get distionaries instead of list? {'col1': 'v...