sql

SQL 2008 table locked - can't work out why

I have two databases on one SQL 2008 server. Database 1 seems to be causing a lock on a table on database 2. There no queries are running on database 1 that should affect database 2. Is this normal behaviour? When I view the running queries with this command SELECT sqltext.TEXT, req.session_id, req.status, req.command, req.cpu_time, r...

"SELECT DISTINCT" ignores different cases

Hello, I have the problem, that MSSQL Server 2000 should select some distinct values from a table (the specific column is of the nvarchar type). There are the sometimes the same values, but with different cases, for example (pseudocode): SELECT DISTINCT * FROM ("A", "a", "b", "B") would return A,b But I do want (and do expect) A,a...

how to read the data from a text file stored in the database

I have a text file stored in my sql DB. in that .txt file I have certain numbers like: 99435 87889 33455 33555 34556 How to get the count of these numbers from the txtfile stored in the database? Also to read the file and fetch the number one by one in a string? I am using asp.net (C#) ...

SQL: column <> '%TEST%' does not work, why?

Hi, I do not understand why following code does not work? SELECT [column1], [column2] FROM table where Column1 <> ('%TEST%') ORDER BY 1 I want to have all rows where Column1 does not contain TEST Thanks ...

Filling a LOV in Oracle Apex based on data in another text box

I am fairly new to Oracle Apex, and have a problem. Our application currently has a method of entering data, with several text boxes and Optional List of Values. I would like to have an LOV based on information in another text box like so: select APPOINTMENT_ID PATIENT_ID from APPOINTMENT where PATIENT_ID = :P9_PAT_NUM where P9_PAT_NU...

SQL RENAME TABLE command

Hello. I can run RENAME TABLE student TO student_new ; The command is same and easy to follow. Is there a methods to rename a lot of tables in simple command. Assume all the tables belog to the same DB name. I don't need write a lot of code as below? RENAME TABLE pre_access TO pre_new_access; RENAME TABLE pre_activities TO pre_new_ac...

Referencing outer query's tables in a subquery

Is it possible to reference an outer query in a subquery with MySQL? I know there are some cases where this is possible: SELECT * FROM table t1 WHERE t1.date = ( SELECT MAX(date) FROM table t2 WHERE t2.id = t1.id ); But I'm wondering if something like this could work: SELECT u.username, c._postCount FROM User u INNER JOIN...

SQL dealing with rubbish in a phone number field

Hello stackers! I've got a wonderfully fun little SQL problem to solve today and thought I'd ask the community to see what solutions you come up with. We've got a really cool email to text service that we use, you just need to send an email to [email protected] and it will send a text message to the desired phone number. F...

How do I quickly explore objects in SQL Server Management Studio

Using SSMS Object Explorer to click through explorer tree against a database with many tables, stored procedures, views, ... can be time consuming, and inefficient way to gain access to specific objects while developing. Are there any tools to allow for quick access to objects? ...

Is SSIS suitable for my problem (database replication for query)

I have a challenge that I am trying to solve and I can't work out from the documentation or the examples if SSIS is suitable for my problem. I have 2 tables (jobs and tasks). Jobs represent a large piece of work, while tasks are tied to jobs. There will typically be anything from 1 task per job to 1,000,000 tasks per job. Each task has ...

SQL query to select records from three Tables seperatly

SQL query which select the record from three tables and there is no relation between these tables. Actually I want to make it a VIEW. suppose there are three tales Table1, Table2, Table3 I want to show records of Table1 first with some filter criteria and then the records from Table2 and in last from Table3 as when we execute the vi...

SQL - suppressing duplicate *adjacent* records

I need to run a Select statement (DB2 SQL) that does not pull adjacent row duplicates based on a certain field. In specific, I am trying to find out when data changes, which is made difficult because it might change back to its original value. That is to say, I have a table that vaguely resembles the below, sorted by Letter and then by...

How to fix this simple SQL query?

I have a database with three tables: user_table country_table city_table I want to write ANSI SQL which will allow me to fetch all the user data (i.e. user details including the name of the country of the last school and the name of the city they live in now). The problem I am having is that I have to use a self join, and I am gett...

problem with IN clause in SQL

Hello, We have observed that there seems to be a maximum number of ids/variables which one can pass in the IN clause of SQL as comma separated values. To avoid this we are storing all the ids in a table and doing a SELECT within the IN clause. This however means extra database operations to store and retrieve ids. Is there any other way ...

I don't find the sql request

Hi everybody, Here it's my problem I've a list of the following measure : src1 dst2 24th december 2009 src1 dst3 22th december 2009 src1 dst2 18th december 2009 I would like to have just the latest measures with a sql request -> 2 first lines in my case because the pairs(src and dst) aren't the same. I try to use DISTIN...

How to deserialize to Report2008?

Hi: I have a Report Service running as a web service. I call the web service to get the RDL back as a byte(), then I call XmlSerializer to cast it to a "Report" type autogenerated by the report service The following code works just fine for SQL2005, but it would throw and exception for SQL2008, when tries to deserialize so if the report...

Comparing textbox.text value to value in SQL Server

Okay so I am trying to compare a login textbox password and username with a custom validator using linq to get information from the database it always returns false though on the validator could someone please tell me where my code below is going wrong. This will be very much appreciated... thank you in advanced... protected void LoginV...

Vendor neutral SQL

I'm currently working on a project for a web application that may be installed on several different servers with various software configurations. I want to make my application as flexible as possible by allowing the user to have various SQL servers installed. The problem is the SQL syntax used by any two server vendors does not match up....

c# Column datatype Date type (NOT DateTime)

Hi All: I want know is there good way to detect Column DataType for Date field (NOT DateTime)? This what currently I do: switch (dt.Columns[col].DataType.FullName) { case "System.DateTime": formatedVal = Formatter.GetDateTime(val); break; // which is NOT possible, but something equivalent am looking fo...

convert sql to linq sample

Hello, I've got a sql statement, but I can't get it working in linq. Can someone show me how I can write the following sql statement as linq? SELECT * FROM mobileApplication LEFT JOIN videoMobile ON mobileApplication.id = videoMobile.mobileApplicationId AND videoMobile.videoId = 257 It's a left join with a where statement on th...