sql

VB.net and SQL Question

I've just started to learn VB.Net and SQL. Now I'm creating my first software but I have a problem: I have two tables in my database and I managed to transfer data from table1 to table2. How can I just insert specific rows from table1 to table2. I don't want to copy all the data in table1 to table2; I just want to copy the selected rows....

Help with simple SQL Query

Table A Id Name 1 Apple 2 Mango Table B Id Locale Name_In_Lang 1 es-ES Apple[Spanish] 1 it-IT Apple[Italian] 2 it-IT Mango[Italian] Join the table and get the following output: Id Locale Name_In_Lang Name 1 Apple 1 es-ES Apple[Spanish...

Count number of users from a certain country

Hi everybody, I have a table of users, and in this table I have a country field telling where these people are from (i.e. "Sweden", "Italy", ...). How can I do a SQL query to get something like: Country Number Sweden 10 Italy 50 ... ... Users select their countries from a list I give to them, but the list is re...

SQL FULLTEXT Search specific XML nodes within an XML column

I would like to know if it's possible to do a Full-Text search on specific XML nodes within a cataloged XML column. XML Sample: <Items> <Item> <Field>first_name</Field> <Data>John</Data> </Item> <Item> <Field>last_name</Field> <Data>Doe</Data> </Item> </Items> I'm able to query by individual field using XPATH ...

SQL Select a row and store in a SQL variable

So, I'm writing this Stored Proc and I really suck at SQL. My Question to you guys is: Can I select an entire row and store it in a variable? I know I can do something like: declare @someInteger int select @someInteger = (select someintfield from sometable where somecondition) But can I select the entire row from sometable and stor...

Find duplicate rows in database.

How do find duplicate rows? If last_name is the duplicate field, I want to have to display last_name frst_name frst_name1 frst_name2 .... Any database will do, prefer oracle. ...

Better query for joins

Ok so I have three tables like so Students Name StudendId ---------------------- John 1 Jane 2 Bob 3 Betty 4 Class StudentId TeacherId ---------------------- 1 1 2 2 3 1 4 2 1 3 4 3 Teacher Name Teacher...

bind radio button list to column in gridview

I have radio button list in a gridview that needs to be bound to a column. If the value in a column is 0, the first radio button is selected, if 1, the other is selected. This is the code, some of it is partially removed because it is not necessary <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<>" SelectC...

Dynamic JOIN condition on a Table

I want to avoid string concatenation to create dynamic SQL query in SQL 2008. How can I achieve the below functionality, if at all, efficiently ? A table stores the various conditions a user had chosen to search DB by using one or more values to search tables from. For e.g. he can give SSN or DOB or both SSN and DOB. So if he gives mu...

Where is the "LINQ to SQL Overview" video featuring Luca Bolognese?

Hi all, I very much like the said video on LINQ, as it is very instructive to newbies on LINQ and I often shared that link. However, the video is no longer available (as it was) via the following link: http://www.microsoft.com/emea/msdn/spotlight/sessionh.aspx?videoid=716 ,which is referred to from http://blogs.msdn.com/b/lucabol/archi...

need help with SQL MAX() in multiple query string

I have a string of 3 queries that are designed to find which messages have other messages with the same id which represents replies find which messages of the results from the first query have the specified user as entering the first message of that string of messages (min timestamp) find the latest message of that string of messages ...

MySQL IN Operator

hi friends, http://pastebin.ca/1946913 When i write "IN(1,2,4,5,6,7,8,9,10)" inside of the procedure, i get correct result but when i add the id variable in the "IN", the results are incorrect. I made a function on mysql but its still not working, what can i do? ...

SQL Finding multiple-line duplicates

At my worki we have data stored in a database, the data is not normalized. I am looking for a way to find what data was duplicated. Our Data base has 3 rows columns, Name, State, Strategy This data might looks something like this: OldTable: Name | State | Strat -----+-------+------ A | M | 1 A | X | 3 B | T | 6 C ...

In Oracle, a way for Updates to not lock rows?

I have an Update query that recalculates -every- column value in exactly one row, each time. I've been seeing more row-level lock contention, due to these Update queries occurring on the same row. I'm thinking maybe one solution would be to have subsequent Updates simply preempt any Updates already in progress. Is this possible? Does ...

How to use Oracle Indexes

I am a PHP developer with little Oracle experience who is tasked to work with an Oracle database. The first thing I have noticed is that the tables don't seem to have an auto number index as I am used to seeing in MySQL. Instead they seem to create an index out of two fields. For example I noticed that one of the indexes is a combinati...

preparedstatment error

I have two select statements and make 'union all' for these two statements. Then, I use the PreparedStatement and when I setString to this preparedStatement, it shows "java.sql.SQLException: Missing IN or OUT parameter at index:: 2". After I toured around google, some people say that for each "?" in sql statment, I should write setStri...

Making Java String usable for a SQL Script

If I have a string that looks like this: This is a string with single quotes ' all over the ' place as well as return characters How would I convert this to a string that can be used in an INSERT statement? INSERT INTO MyTable VALUES ('<the above string>'); The string above has the problems that it has return characters as well as ...

Can the same column have primary key & foreign key constraint to another column

Can the same column have primary key & foreign key constraint to another column? Table1: ID - Primary column, foreign key constraint for Table2 ID Table2: ID - Primary column, Name Will this be an issue if i try to delete table1 data? Delete from table1 where ID=1000; Thanks. ...

How to view/verify a procedure result?

Can someone explain how to see the results of a procedure, everything is working fine and the code is valid, executed and compiled with no errors. Now how can I see the results as Query or anything. The ex procedure is about sum of salary. CREATE OR REPLACE PROCEDURE HR.TOTAL_SALARY AS total_salary NUMBER(12,2); BEGIN ...

Mysql to SQL Server: is there something similar to query cache?

Hi, I'm trying to optimize a SQL Server. I have some experience with Mysql and one of the things that usually help is to enable query cache, that will basically cache query results as long as you are running the same query. Is there something similar to this on SQL Server? Could you please point what is the name of this feature? Thank...