sql

Cascading Deletes in SQL Sever 2008 not working.

I have the following table setup. Bag | +-> BagID (Guid) +-> BagNumber (Int) BagCommentRelation | +-> BagID (Int) +-> CommentID (Guid) BagComment | +-> CommentID (Guid) +-> Text (varchar(200)) BagCommentRelation has Foreign Keys to Bag and BagComment. So, I turned on cascading deletes for both those Foreign Keys, ...

ignore some values in insert into select from sql stament

Suppose that I have a Table Symbols(Symbol, Value) and a Table SymbolValues (Symbol, Value) which contains a list of values for the symbol. How to choose maximum values fromt he SymbolValues table and insert into Symbols table. For Example, The SymbolValues Table has following values A 1 A 2 A 3 B 6 B 7 Then only A 3 and B 7 should b...

How do I select the max value from multiple tables in one column

I would like to get the last date of records modified. Here is a sample simple SELECT: SELECT t01.name, t01.last_upd date1, t02.last_upd date2, t03.last_upd date3, 'maxof123' maxdate FROM s_org_ext t01, s_org_ext_x t02, s_addr_org t03 WHERE t02.par_row_id(+)= t01.row_id and t03.row_id(+)= t01.pr_addr_id and ...

Why use a READ UNCOMMITTED isolation level?

In plan English what are the disadvanges and advantages of using SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED in query for .NET applications and reporting services application? ...

SQL server - climb up in the tree structure

Hello. I have some sql table, named Object, which saves tree data in fields ObjectID, ParentID, and others. I have implemented recurse procedure, which select everything down by objectID from tree, like this: 1. 1.1. 1.2. 1.2.1. ... Now o need to "Climb up" - by some ObjectID i need to select everything Up, like this: 1.2.1. 1.2. 1. ...

Convert db data encoding to UTF-8

Hi, I use Sql Server 2000 and I inserted some data in hebrew to a table. I need to access this data through an iPhone app using an ASP page that query the table. The problem is that in the iPhone app the Hebrew is shown as strange signs. I think my problem is that the data that is generated from my db isn't in UTF-8 but in USC-2 Any sugg...

SQL Query: How to determine "Seen during N hour" if given two DateTime time stamps?

Hello all. I'm writing a statistics based application off a SQLite database. There is a table which records when users Login and Logout (SessionStart, SessionEnd DateTimes). What i'm looking for is a query that can show what hours user have been logged in, in sort of a line graph way- so between the hours of 12:00 and 1:00AM there we...

NHibernate: How to show the generated SQL-statements in the windows console

return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString(c => c .Database(Database) .TrustedConnection() ...

how to clear individual columns in oracle?

hey, i wrote a java app that communicates and stores data in oracle; my question is how do i clear entered information from individual columns in oracle? for example, say i have a following table: create table example (id integer, name varchar(50), surname varchar(50)); and it contains current information, how do i then clear in...

Help with my application please! Can’t open image(s) with error: External component has thrown an exception…

I have an application written in C# I believe and it adds images to a SQL Server 2005 Database. It requires .NET 3.5 to be installed on my computer. I installed .NET 3.5 and setup a database. It runs fine but then once it gets to image 100 when running on one computer, It stops and gives me this error: Can't open image(s) with error: Ext...

Oracle .dmp file

I have an oracle .dmp file, and no access to a local oracle install.. Is there any way I can read the data or open it in another program to see what data is in this file? ...

Best way to compare contents of two tables in Teradata?

When you need to compare two tables to see what the differences are, are there any tools or shortcuts you use, or do you handcode the SQL to compare the two tables? Basically the core features of a product like Red Gate SQL Data Compare (schemas for my tables typically always match). Background: In my SQL Server environment, I created ...

Best way to produce automated exports in tab-delimited form from Teradata?

I would like to be able to produce a file by running a command or batch which basically exports a table or view (SELECT * FROM tbl), in text form (default conversions to text for dates, numbers, etc are fine), tab-delimited, with NULLs being converted to empty field (i.e. a NULL colum would have no space between tab characters, with appr...

Receiving a NullPointerException when calling a cursor in Android

I am creating an application which tracks the users location using GPS, stores the longitude and latitude in a database using a content provider then output the first long and lat to a mapview. I am able to create the cursor using this line of code: Cursor c = getContentResolver().query(GPSContentProvider.CONTENT_URI, ...

JOIN in SQL with one-to-many relationship

I'm making a tool to track calls to house/senate reps, and I have 2 tables of importance here: reps rep_id rep_name # and more info comments rep_id status # enum about result of contact comment I want to query for all reps joining the most recent associated comments and in some cases joining comments of a specific status, but ther...

Make SQL Select same row multiple times

I need to test my mail server. How can I make a Select statement that selects say ID=5469 a thousand times. ...

Why am I getting "Enter Parameter Value" when running my MS Access query?

In my query, I use the IIF function to assign either "Before" or "After" to a field named BeforeOrAfter using AS. When I run this query, however, the "Enter Parameter Value" dialog appears, requesting a value for BeforeOrAfter. If I remove BeforeOrAfter DESC from the ORDER BY clause, I don't get the dialog. Here is the offending query:...

Computed column should result to string

Here is a snap of my database. Both col1 and col2 are declared as int. My ComputedColumn currently adds the Columns 1 and 2, as follows... col1 col2 ComputedColumn 1 2 3 4 1 5 Instead of this, my ComputedColumn should join the columns 1 and 2 (includimg the '-' character in the middle) as follows... col1 col2 C...

SQL Temp Tables & Replication

I have had an issue with our replication process and would like to salvage some data. I have a process in place where I will connect to each subscriber before flagging them for reinitialization and I will run the below to pull any data they may have entered in during the "dark time". I am pretty sure this will work in a vanilla palace...

Possible to view T-SQL syntax of a stored proc-based SqlCommand?

Hello! I was wondering if anybody knows of a way to retrieve the actual T-SQL that is to be executed by a SqlCommand object (with a CommandType of StoredProcedure) before it executes... My scenario involves optionally saving DB operations to a file or MSMQ before the command is actually executed. My assumption is that if you create a Sq...