Can some tell me what i am doing wrong
SELECT SUM(CAST(Admin As numeric (18,2)))+ SUM(CAST(PaidOT As numeric(18,2))) + SUM(CAST(UnpaidOT As numeric(18,2))) AS Total, IBMNum
FROM dbo.DSPActivitySheet
Where (dt BETWEEN @dt AND @dt2 )And( IBMNum=@IBMNum)
GROUP BY IBMNum
I get " error Converting data type varchar to numeric"
5 1047
Can some tell me what i am doing wrong
SELECT SUM(CAST(Admin As numeric (18,2)))+ SUM(CAST(PaidOT As numeric(18,2))) + SUM(CAST(UnpaidOT As numeric(18,2))) AS Total, IBMNum
FROM dbo.DSPActivitySheet
Where (dt BETWEEN @dt AND @dt2 )And( IBMNum=@IBMNum)
GROUP BY IBMNum
I get " error Converting data type varchar to numeric"
It can be at a number of places. Can you please post your table structure and variable declarations?
It can be at a number of places. Can you please post your table structure and variable declarations?
here is the table
CREATE TABLE dbo.DSPActivitySheet(
Id int PRIMARY KEY CLUSTERED,
dt SMALLDATETIME,
IBMNum real,
Hours_On_Duty Varchar(50),
UnpaidOT Varchar(50),
PaidOT Varchar(50),
Admin Varchar(50),
Court Varchar(50),
INSTR Varchar(50),
STDNT Varchar(50),
COMM_SERV Varchar(50),
VICT_SERV Varchar(50),
Remarks Varchar(50)
);
GO
Hi,
I have an SQL table which uses a primary key that is an automatically generated 32 bit integer, assigned by SQL when a new record is added to the table. None of the other fields can be guaranteed to be unique. When I add a new record, I need to know what primary key was allocated so that I can refer to the record uniquely, but there seems to be no neat way of finding it out.
I can think of two messy ways to do it as follows:
1) Temporarily put a large random number in one of the fields and search for it.
2) Add a timestamp and search for the last modification in the table.
Any better ideas?
Many thanks, Chris.
Hi,
I have an SQL table which uses a primary key that is an automatically generated 32 bit integer, assigned by SQL when a new record is added to the table. None of the other fields can be guaranteed to be unique. When I add a new record, I need to know what primary key was allocated so that I can refer to the record uniquely, but there seems to be no neat way of finding it out.
I can think of two messy ways to do it as follows:
1) Temporarily put a large random number in one of the fields and search for it.
2) Add a timestamp and search for the last modification in the table.
Any better ideas?
Many thanks, Chris.
There are several ways. The simplest is that the key increments by one at each insert, so the largest one is the last. Another one is that you can catch insert with an insert trigger.
here is the table
CREATE TABLE dbo.DSPActivitySheet(
Id int PRIMARY KEY CLUSTERED,
dt SMALLDATETIME,
IBMNum real,
Hours_On_Duty Varchar(50),
UnpaidOT Varchar(50),
PaidOT Varchar(50),
Admin Varchar(50),
Court Varchar(50),
INSTR Varchar(50),
STDNT Varchar(50),
COMM_SERV Varchar(50),
VICT_SERV Varchar(50),
Remarks Varchar(50)
);
GO
A few declarations are still missing. I set up the following and it works fine for me. -
declare @dt as datetime, @dt2 as datetime
-
declare @IBMNum as real
-
Thus I suppose some of your variable declarations are not OK.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: laurie |
last post by:
Hi all,
I'm trying to help out a friend who has inherited a client with a PHP
shopping cart application. Neither of us know PHP, but I've been
muddling my way through, trying to get these old...
|
by: the_proud_family |
last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com
I can't get the ball to go up right side and then I need it to turn
around and keep turning until velocity=0 I have been at it for the
...
|
by: Kurt Watson |
last post by:
I’m having a different kind of problem with Hotmail when I sign in it
says, "Web Browser Software Limitations
Your Current Software Will Limit Your Ability to Use Hotmail
You are using a web...
|
by: Christo |
last post by:
borland c++ 5.01
character constant must be one or two characters long
get this when compiling my first c++ program can anyone out there help?
it is highlighting this line as the problem
...
|
by: x muzuo |
last post by:
Hi guys,
I have got a prob of javascript form validation which just doesnt work
with my ASP code. Can any one help me out please.
Here is the code:
{////<<head>
<title>IIBO Submit Page</title>...
|
by: Craig Keightley |
last post by:
Please help, i have attached my page which worksin IE but i cannnot get the
drop down menu to fucntion in firefox. Any one have any ideas why?
Many Thanks
Craig
...
|
by: JT |
last post by:
Help me the following C++ question:
Write a program to help a local bookshop automate its billing system.
The program should do the following:
(a)Let the user enter the ISBN, the system will...
|
by: tyler_durden |
last post by:
thanks a lot for all your help..I'm really appreciated...
with all the help I've been getting in forums I've been able to continue
my program and it's almost done, but I'm having a big problem that...
|
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application...
|
by: =?Utf-8?B?U2NvdHRSYWREZXY=?= |
last post by:
I'm creating a doc project for my c# program. I've done this before but this
time sonething is wrong. I build my doc project and is succeeds but when I
open the help file, there is no documentation...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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,...
| |