473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Need help in writing a Stored Procedure

Hi Everybody,

I am trying to update a column Percentage in a table named Critical Doctors with the a column named PercentTime from tblPercent table, Where the column Doctor matches with any DoctorId from tblPercent.

I am getting an error message for the following query.

update CriticalDoctors set Percentage =
(select PercentTime from tblPercent)
where CriticalDoctors.Doctor = (select DoctorId from tblPercent)

Server: Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

Pls give me reply on how to write a stored procedure so that I can I can equate the percentage column with one value and also check the condition with one value.

Thanking you guys in advance.

madhav
Mar 29 '07 #1
4 1545
Hi

Try this:

Expand|Select|Wrap|Line Numbers
  1. UPDATE CriticalDoctors SET CD.Percentage = TP.PercentTime
  2. FROM CriticalDoctors CD, tblPercent TP
  3. WHERE CD.Doctor = TP.DoctorID
  4.  
Mar 29 '07 #2
I got the following error

Server: Msg 1032, Level 15, State 1, Line 1
Cannot use the column prefix 'CD'. This must match the object in the UPDATE clause 'CriticalDoctors'.


madhav

Hi

Try this:

Expand|Select|Wrap|Line Numbers
  1. UPDATE CriticalDoctors SET CD.Percentage = TP.PercentTime
  2. FROM CriticalDoctors CD, tblPercent TP
  3. WHERE CD.Doctor = TP.DoctorID
  4.  
Mar 29 '07 #3
iburyak
1,017 Expert 512MB
TRy this:

[PHP]
UPDATE CriticalDoctors SET Percentage = TP.PercentTime
FROM CriticalDoctors CD, tblPercent TP
WHERE CD.Doctor = TP.DoctorID[/PHP]
Mar 29 '07 #4
TRy this:

[PHP]
UPDATE CriticalDoctors SET Percentage = TP.PercentTime
FROM CriticalDoctors CD, tblPercent TP
WHERE CD.Doctor = TP.DoctorID[/PHP]
Ya, this is fine
Mar 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Aleem | last post by:
I need help in writing a stored procedure on SQL Server 2000. Basically the stored procedure's primary task is to generate invoice records and insert the records in a invoice table. In order to...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
5
by: Ralph | last post by:
Hi all, I'm a newbie to MS-SQL UDFs and seem to have a real big problem. I need to implement a logic to receive an adress build out of various user definable fields from various user defined...
0
by: Doug R | last post by:
Hello, I have a system that I am writing to automaticly import Credit Transaction data into a SQL Server 2000 Database. I am using a VB.Net application to detect when the file arives and prep...
1
by: T.S.Negi | last post by:
Dear All, Please suggest some of the best practices for writing SQL server stored procedures? I'm writing a business function (stored procedure), which calls many-stored procedure one after...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
3
by: Ellie O'Donnell | last post by:
Hi, I wrote a DB2 stored procedure in COBOL, and now I need to prepare a CLIST in order to call it. This CLIST would be for people who want to use the stored procedure outside of COBOL or Pl/I....
1
by: Jim H | last post by:
I am on a project where I am supposed to send an XML document to a SQL Server stored procedure. The XML Doc is a list strings. If in my c# function I get a list values as (string psValueList),...
2
by: db2learner | last post by:
Hi, I am new to DB2 and i just started worked on it a couple of days back. I have created basic EMPLOYEE table from control centre which has 2 fields: EmpNo, EmpName. I am trying to write...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.