sql

Joins in SQL for retriving data from two tables

There are two tables A and B. You are retreiving data from both tables where all rows from B table and only matching rows from A table should be displayed. Which of the following types of joins will you apply between A and B tables? - Inner join - Left outer join - Right outer join - Self join ...

Regarding sql substitution

Hi, When i ran the below queries it's failing in the second query becuase prev_test_ref1 variable is not defined. If i remove the insert statement in the first query ,run again then it's working and using the prev_test_ref1 value from the first sql query in second query. Is it because of variable scope? How can i resolve this with...

Conversion failed when converting the varchar value 'Blue color' to data type int.

2 Hi! I am trying to create stored procedure that gone return varchar value, and that value I need to display in textbox. This is the code for stored procedure: Create PROCEDURE Status @id_doc int, @Name varchar(50) OUTPUT AS select @Name =items.name from Doc,Items where @id_doc=IDN and doc.IDN=Items.ID return @Name This is t...

drope table mechanism in sql

When a table is dropped using a simple DROP statement, SQL performs some more operations simultaneously, select all the valid operations? a. Removes all rows from the table b. Drops all the table's indexes c. Removes all dependent views d. Removes all dependent procedures ...

Problem in executing different queries based on condition in CASE statement

Hello All, I am facing a problem in executing queries with CASE statement. Based on my condition,(for eg. length), I want to execute different SQL statement. Problematic sample query is as follows: select case when char_length('19480821') = 8 then select count(1) from Patient when char_length('19480821')=10 th...

How do update a date column by changing only the year and not the day or month using PLSQL?

I have a database table containing credit card records. One of the fields is a Date field. I would like to update this field by changing the year portion of the date to 2011 if the year is less than 2010. From what i have found, PLSQL has functions for time and months but nothing to do with years (to my knowledge). ...

when multiple user login then after some time ASP.Net C# Application get slow

In application all sql connection close properly, Also when user log out its connection close still sql process memory increase in RAM and after some time Application slow down. ...

Storing the result of a dynamic text field into separate database fields

I am working within the confines of a php based CMS like system, which defines custom form fields that can be used when making a new page. I have two tables in my database, one called people, which has three fields, firstname, middlename and lastname, and a second table called orders, which also has firstname, middlename and lastname fi...

select the rows affected by an update

How can you get the exact rows affected by an SQL UPDATE statement in MySQL? I have many clients on many computers that can be updating rows in the same table based on WHERE clauses at any time, and each client needs to do something in another system for each row that they affect, so getting the list of affected items must be accurate a...

SQL Server 2005 Stored Procedure Using Table Variable Doesn't Return ResultSet to VB6 App

I have a stored procedure which selects a single field from a single row (based on a conditional statement) and stores it in a local variable. Based on the value of this field I update the same field in the same row of the table (using the same conditional statement). So the procedure first does a select into a local variable and then ...

taking text from an autogenerated autocompelte field, and pushing it back to php with jquery

I have a google suggest type of input field, which displays records)the result of an SQL query) as I type input. I can then select one, and what I select becomes the content of that field. I would like to know how to push the content of that variable back to my PHP form using jquery. I am working in the confines of phpBMS, a type of CM...

What permissions are required to query master..syslogins in SQL Server?

I have readonly access to the master database however the following query only returns a subset of users. What permissions are needed to return the rest of the users? SELECT [name] FROM master.dbo.syslogins ...

Max value in a many-to-many relationship

I'm using SQL Server 2008 and I have 3 tables, x, y and z. y exists to create a many-to-many relationship between x and z. x y z -- -- -- id xid id zid sort All of the above fields are int. I want to find the best-performing method (excluding denormalising) of finding the z with the highest sort for ...

need help for planning software development , database design

I have been doing a coding in for last 7 months. Most part of it has been the updations to the very poorly coded software in asp. Now I am going to redevelop entire software in asp.net. I want it to be very efficient. I need some tips and guidance about how to plan project and design a good database. Thanks in advance for help. ...

How to join in SQL on a PHP serialized primary key

Ok this is weird, I know. I just want ideas about how to deal with it. I want to do a join --- --- A B --- --- id id idB --- --- A standard join would be : SELECT * FROM B JOIN A ON A.idB = B.id WHERE A.id = 3 But here, my idB is not an int foreign key, it is PHP serialized. For example, instead of being 5, it is "i...

sp_notify_operator: The specified @operator_name does not exist (but it does!)

OK, so I think I'm going mad here! Here's where I am. SQL Server 2008: I've set up Database Mail, and I've sent myself a test email. Simple, works fine. I've created an operator, called 'Tom'. I've given it an email address (but nothing else). However, when I run this command: EXECUTE msdb.dbo.sp_notify_operator @name=N'Tom',@subj...

Incorrect syntax near '-'

i am trying to run a query in another server and need to specify it in the select statement but the server name has got an '-' in it, like server-name. this is producing the error in the title. How can i fix it? ...

Is there a C# IN operator?

In SQL, you can use the following syntax: SELECT * FROM MY_TABLE WHERE VALUE_1 IN (1, 2, 3) Is there an equivalent in C#? The IDE seems to recognise "in" as a keyword, but I don't seem to be able to find any information on it. So, is it possible to do something like the following: int myValue = 1; if (myValue in (1, 2, 3)) // D...

Join with Zend_Db, without having the columns of the joined tables

Hi, I use Zend_Db_Select to perform a query with a Join. I end up with the following SQL query : SELECT `Utilisateur`.*, `Ressource`.*, `Acl_Cache`.*, `Role`.*, `UtilisateurRole`.* FROM `Utilisateur` INNER JOIN `Ressource` ON Ressource.idJointure = Utilisateur.id INNER JOIN `Acl_Cache` ON Acl_Cache.idRessource = Ressource.id INNER JOIN...

how to find fifference between 2 dates in DB2

In my database i have a TIMESTAMP field.Now I want to find the difference between the value stored in this field and the current TIMESTAMP .I want the result in days. How can i get it? Note:I am using DB2 database ...