sql

Cannot use the ROLLBACK statement within an INSERT-EXEC statement.

Cannot use the ROLLBACK statement within an INSERT-EXEC statement I am using two stored procedures. the first sp returns some int value I am using this in the second sp with INSERT EXEC But when i am executing the second sp , I am getting the above error Please help ...

Delete duplicate rows accoding to condition

I am using PostgreSQL database. I have the data like below. id name1 name2 modified_date - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 40 Balfe | Pat | 2010-10-01 17:48:44.804823 41 Battigan | David | ...

Web bot problem.

I have a database generated page which shows lots of links. This page consists of 3 colums. In the first column, it gets the links from the database. In the second column it generated + links, and in the last column, it generated a - link So basically, each row generated consists of a url link, a + link and a - link. When the user ...

What are the disadvantage of SQL views?

Recently I faced an interview and I was asked the above question. I was dumb when I think about it. Interviewer said: All people are saying views have lots of advantages but I find no disadvantages, why so? EDIT Based on the answers of all experts, I think I can summarize it: When table is dropped or modified, view become...

Search - Order By Keywords

Is there any way to do something like this: var keywords = SearchUtilities.FindKeyWords(q); var j = (from p in _dataContext.Jobs orderby p.JobKeywords.Select(jobKeyword => jobKeyword.Keyword) .Intersect(keywords).Count()) .Take(10).AsEnumerable(); The main idea here is to order search results by the co...

MySql stored procedures, delete record logically or phisically depending on existing table references

Hi, I have to write a Stored Procedure to delete record from a table. I have a memory table "tableids" where I store all the ids to delete from another table, say "addresses". CREATE TABLE `tempids` ( `id` INT(11) NULL DEFAULT NULL ) COLLATE='latin1_swedish_ci' ENGINE=MEMORY ROW_FORMAT=DEFAULT I could do this: DELETE FROM addr...

How to use CREATE LOGIN sql statement?

Hi, How to use CREATE LOGIN statement on SQL Server 2005? I was trying nearly everything, with commas, without them, with strings, without them etc. CREATE LOGIN @loginame WITH PASSWORD = 'pass', DEFAULT_DATABASE='dbname' DEFAULT_LANGUAGE='us_english', CHECK_POLICY= OFF; I always get below error: Incorrect syntax near the keyword '...

Finding total deductions based on sum of prior rows in SQL

I've got a rather tricky problem that I've been trying to solve for the past few days. I am currently solving it with the Oracle SQL Model clause and could probably have written a function but I'm looking for a nice simple solution using analytic functions or something but can't figure anything out. For a given policy (ddpsid), I want t...

RIA DomainService Local SQL OK, Remote SQL Not Found.

I am using a DomainService with .NET4, EF4. It is working from my local SQL Server, when I change the connection string to the remote SQL server which has the same schema and data in it, shallow queries run normally. When a query which contains .Include("child_table_name") in the ObjectQuery and [IncludeAttribute] on the entity property...

SQL Query - select data from table A based on two fields in table B

I have two tables: A: [ date, step, status, ... ] B: [ date, step, name, ... ] I want to get result in form of [date, step, name] based on status parameter. I can easly get data from table A using following query: Select date, step From A Where status='1' and the result would be like: 1. 2010-09-12; 5 2. 2010-09-13; 3...

Transaction in firebird 1.5

How to make transaction using IB Expert? I need a manual or something like begin transaction create table someTable(a int,b int) insert into someTable values(1,2) insert into someTable values(3,4) commit transaction but working in Firebird to see the syntax. ...

Full Text Search Help

In a SQL Server database I've two tables: Job and JobKeyword. Each Job has JobKeywords. I'm trying to learn how to use Full Text Search. How can I get a list of all jobs in the databases, ordered by shared keywords between the search query and the jobs? ...

How can i check in MS SQL Server 2005 if a column is of a specific type

Hi, I want to change the type of a column in MS SQL Server 2005, but before i change the type of that column i want to check if that column is of the type i want to change. How can i do that in SQL? Thanxs, Bas Hendriks. Based on the anwser i wrote the following query that did the trick: IF NOT EXISTS (SELECT * FR...

When I do a filter with WHERE on a View, are the indexes used?

I have a view created from many tables with multiple fields. When I issue a WHERE filter on the View, are the table's indexes in use? ...

transport-level error when specifying SELECT *

The following query does not work, and produces an error: A transport-level error has occurred when receiving results from the server SELECT * FROM table1 a, table2 b, table3 c WHERE a.location = b.location AND b.location = c.location AND a.id = c.id AND a.entry = ''34690'' Although this ...

Calling a stored procedure using LINQ to SQL with a Custom Entity Class

Hi Am trying to get linq to call a stored procedure. I know this is usually rather simple, but in this case i am using my own Custom Entity Classes and I am at a dead end. the link below will show you how I have my OM setup example does any one know how you can call a stored procedure from your own Custom Entity Class? EDIT: Forg...

SQL query to update top 1 record in table.

Can anybody please tell me how to write query to update top 1 record in table ? Thanks ...

Left Joining on Multiple Tables with Timestamps

Ok SQL and Oracle gurus I have a somewhat complicated query that I'm trying to build. Here is my current query: select distinct person_info.person_name table2.value, table3.value, table4.value, table5.value from person_info left join table2 on table2.person_name=person_info.person_name left join table3 on ta...

SQL plus running multiple queries

I have 12 queries to run, but can not run at the same time. I would like to start the first query, then as soon as it completes the next query begins, when it completes the third query starts and so on. Want this to be automatic. Each query writes a txt file. Thanks ...

Find and replace column values with Microsoft SQL?

I have a column called <locations>, I want to find all matching values (ex: Canada) and replace with a different value (ex: Mexico). How do I go about that? Thanks. ...