sql

oracle sql developer is truncating my results

I'm calling a stored function like this: select XML_INVOICE.GENERATE_XML_DOC('84200006823') from dual; The query results then show up in a table underneath, which I can right click and select "Export Data" -> XML <?xml version='1.0' encoding='UTF8' ?> <RESULTS> <ROW> <COLUMN NAME="XML_INVOICE.GENERATE_XML_DOC('84200006823')" <...

Verify two columns of two different tables match exactly.

When writing views and nesting views within deeper views I sometimes miss something and end up losing rows/data. How can I check that columns from two different tables have an exact match of data? Example: select count(distinct table1.col1) from table1 where table1.col1 not in (select distinct table2.col1 ...

MySQL get data from another table with duplicate ID/data

How to query data from table_1 which ID is not available on table_2 that has duplicate ID's. See example below. I want to get ID 5 and 6 of Table 1 from Table 2 Table 1 ------------- | ID | Name | | 1 | a | | 2 | b | | 3 | c | | 4 | d | | 5 | e | | 6 | f | ------------- Table 2 ------------- Table 1 ID | | 1 ...

Using pyodbc to insert rows into a MS Access MDB, how do I escape the paramaters?

Hi, I'm using pyodbc to talk to a legacy Access 2000 .mdb file. I've got a cursor, and am trying to execute this: c.execute("INSERT INTO [Accounts] ([Name], [TypeID], [StatusID], [AccountCat], [id]) VALUES (?, ?, ?, ?, ?)", [u'test', 20, 10, 4, 2]) However, doing so results in pyodbc.Error: ('HYC00', '[HYC00] [Microsoft][ODBC Mic...

PHP tag cloud ( and finding similar ones )

Hello! I have articles on my site, and I would like to add tags which would describe each article, but I'm having problems with design mysql table for tags. I have two ideas: 1) each article would have field "tags", and tags would be in format: "tag1,tag2,tag3" 2) create other table called tags with fields: tag_name, article_id, so when...

SQL Select table1.columa as table1.columb

I am working on a database join and I want to do the following: Select tabel_one.id, tabel_one.title, tabel_one.content, table_two.value as table_two.key from tabel_one Join table_two ON table_two.id = table_one.id .... The Important part is: table_two.value as table_two.key Is there a way this could w...

Alter Table Filestream runs even if IF statement is false

I am writing a script to update a database to add Filestream capability. The script needs to be able to be run multiple times without erroring. This is what I currently have IF ((select count(*) from sys.columns a inner join sys.objects b on a.object_id = b.object_id inner join sys.default_constraints c on c.parent_obje...

how to generate dbml file from Sybase database?

I think we may have trouble with our existing project. For some reasons we have to switch from SQL Server to Sybase SQL Anywhere 11. now we trying to find a way continue use our existing LINQ code. We wish we can still use L2S? If cannot, we wish we can use L2E, then we have to change to ADO. how to generate dbml file from Sybase Anyw...

using construct with sqlTransaction dependent on number of different action results ...

I'm curious if following code would be considered safe? using (SqlConnection cn = new SqlClient.SqlConnection(connectionString)) { cn.Open(); using (SqlTransaction tr = cn.BeginTransaction()) { try { if (!Data.DoSomething1(tr, p1, p2)) { tr.Rollback(); return false; ...

Can I modify package.xml file in SQL bootstrapper to install a named SQL server instance

I want to use the SqlExpress2008 Bootstrapper for a new installation on Windows7, I do not want to use the default SQLEXPRESS Instance. I have attempted to edit the package.xml file located in: C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\SqlExpress2008\en\package.xml and updated the command argument instan...

Is there a library / tool to query MySQL data files (MyISAM / InnoDB) without the server? (the SQLite way)

Oftentimes I want to query my MySQL data directly without a server running or without having access to the server (but having read / write rights to the files). Is there a tool or maybe even a library around to query MySQL data files like it is possible with SQLite? I'm specifically looking for InnoDB and MyISAM support. Performance is ...

How to change the primary key to be non-clustered?

Part-time reluctant DBA here. I want to change an existing primary key index from clustered to non-clustered. And the syntax is escaping me. This is how it's scripted out right now. ALTER TABLE [dbo].[Config] WITH NOCHECK ADD CONSTRAINT [PK_Config] PRIMARY KEY CLUSTERED ( [ConfigID] ) ON [PRIMARY] I am not...

SQL INSTR() using CSV. Need exact match rather than part

This is a follow up issue relating to the answer for http://stackoverflow.com/questions/2445029/sql-placeholder-in-where-in-issue-inserted-strings-fail Quick background: We have a SQL query that uses a placeholder value to accept a string, which represents a unique tag/id. Usually, this is only a single tag, but we needed the ability to...

NHibernate - I have many, but I only want one!

Hello, I have a User which can have many Emails. This is mapped through a List collection (exposed by IEnumerable Emails on the User). For each User one of the Emails will be the Primary one ("Boolean IsPrimary" property on Email). How can I get the primary Email from User without NHibernate loads every email for the User ? I have the...

Checking inherited attributes in an 'ancestry' based SQL table

I'm using the ancestry gem to help organise my app's tree structure in the database. It basically writes a childs ancestor information to a special column called 'ancestry'. The ancestry column for a particular child might look like '1/34/87' where the parent of this child is 87, and then 87's parent is 34 and 34's is 1. It seems possib...

How to record different authentication types (username / password vs token based) in audit log

I have two types of users for my system, normal human users with a username / password, and delegation authorized accounts through OAuth (i.e. using a token identifier). The information that is stored for each is quite different, and are managed by different subsytems. They do however interact with the same tables / data within the syste...

trigger execution against condition satisfaction

I have created this trigger which should give a error, whenever the value of new rctmemenrolno of table-receipts1 is matched with the memenrolno of table- memmast, but it is giving error in both condition(it is matched or not matched). kindly help me. CREATE OR REPLACE TRIGGER HDD_CABLE.trg_rctenrolno before insert ON HDD_CABLE.RECEIPTS...

Using sql column names in hibernate createSQlquery result

Hi all, i have a couple of sql views with composite primary keys that i want to query, and since Hibernate makes it a pain to work with composite keyes, im using createSQLQuery. The problem is that this method can only return a List, and i need to refer to the colums by their index. Any chance i could do like jdbc and refer to the col...

Ruby way in model logic

Hi everybody! I'm junior rails programmer. I have some optimization questions about eager loading and Models at all. So I have such relationships: Program --< Subprograms --< Events --< Financings \--<Events --< Financings Program and subprogram is self-referrental sti models. I need to have a bunch of virtual fields in event...

Locking User account created under Windows Authentication in SQL Server

Hi, As per my project requirement i need to lock a user in SQL Server(Which is created using Windows Authentication). Is there any way to do this? For example: For a SQL login if you try to login using wrong Password more than 3 or 4 attempts, then that account gets locked out. User cannot login to SQL Server using this username. I wan...