473,581 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using the AS clause in a SQL stored proc -- problem using datetime column

I'm trying to concatenate fields in SQL stored proc for use in text
field in asp.net dropdownlist. I'm running into a problem when I try
to use a DateTime field, but can't find the answer (so far) on the
Internet. Was hoping someone here would know?

My sql stored proc:

SELECT AnomalyID, DateEntered + ', ' + Station + ', ' + Problem As
'SelectInfo'
FROM tblAnomaly
WHERE WorkOrder=@varW O AND Signoff=Null
ORDER BY DateEntered

but I get the error:
The conversion of a char data type to a datetime data type resulted in
an out-of-range datetime value.

I'm not the brightest bulb on the block, so any clues greatly
appreciated!

Thanks, Kathy
Jul 20 '05 #1
3 3997
Kathy,

You need to convert the DateEntered field. Also pay attention that you can
not compare a field to NULL using "=", use "is" operator insted.
Try this:

SELECT AnomalyID,
convert(varchar , DateEntered, 100) + ', ' + Station + ', ' + Problem
As 'SelectInfo'
FROM tblAnomaly
WHERE WorkOrder = @varWO AND Signoff is null
ORDER BY DateEntered

Shervin

"KathyB" <Ka**********@a ttbi.com> wrote in message
news:75******** *************** **@posting.goog le.com...
I'm trying to concatenate fields in SQL stored proc for use in text
field in asp.net dropdownlist. I'm running into a problem when I try
to use a DateTime field, but can't find the answer (so far) on the
Internet. Was hoping someone here would know?

My sql stored proc:

SELECT AnomalyID, DateEntered + ', ' + Station + ', ' + Problem As
'SelectInfo'
FROM tblAnomaly
WHERE WorkOrder=@varW O AND Signoff=Null
ORDER BY DateEntered

but I get the error:
The conversion of a char data type to a datetime data type resulted in
an out-of-range datetime value.

I'm not the brightest bulb on the block, so any clues greatly
appreciated!

Thanks, Kathy

Jul 20 '05 #2
Thanks, Shervin. And thanks for the quick reply!!!

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Kathy,

I forgot to tell you about the third parameter of CONVERT. This is the style
used to convert datetime type to string. Check Books Online to get the
complete list of acceptable styles.

Shervin

"Kathy Burke" <ka**********@a ttbi.com> wrote in message
news:3f******** *************@n ews.frii.net...
Thanks, Shervin. And thanks for the quick reply!!!

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
10226
by: Alex Vorobiev | last post by:
hi there, i am using sql server 7. below is the stored procedure that is giving me grief. its purpose it two-fold, depending on how it is called: either to return a pageset (based on page number and page size), or to return IDs of previous and next records (based on current record id). the problem is, that the order in which records are...
2
2326
by: jaYPee | last post by:
I have an existing query from MS Access that I want to convert it to SQL Server Stored Proc. My problem is on how to convert the WHERE clause. This is the query from MS Access: SELECT SchYrSemCourseJoin.SchYrSemCourseID, Students.IDNo, & ", " & & " " & AS Name, Program.ProgramTitle, Program.ProgramDesc, SchYrSem.SchYr, SchYrSem.Sem,...
10
3000
by: Jozef de Veuster | last post by:
Hi, I'm trying to create a Stored Procedure that returns a recordset, but I want to be able to choose the ORDER BY clause in mijn parameter list of the Stored Procedure. Since CASE .. WHEN can only be used in the SELECT clause, I came up with the following: -- BEGIN SCRIPT -- DECLARE @blah AS VARCHAR(20) SET @blah = 'DOSSIER_CODE'
9
5267
by: joun | last post by:
Hi all, i'm using this code to insert records into an Access table from asp.net, using a stored procedure, called qry_InsertData: PARAMETERS Long, Long, Text(20), Long, DateTime; INSERT INTO Table ( ID, Cod, CodArt, Q1, DataUscita ) VALUES (pID, pCod, pCod, pQ1, pDataUscita);
1
2763
by: Mok | last post by:
Hello, I want to pull information from a table in sql server, bind it to a grid and update those values. I would like to know the best way to do it. I used the configure data adapter wizard and it came up with a crazy stored proc. As in this example I would only update and : CREATE PROCEDURE . ( @Description varchar(1000),
5
4392
by: ujjc001 | last post by:
two variables declared in my proc: @DATE_RANGE_START as datetime, @DATE_RANGE_END as datetime, When I execute my SP it takes 34 seconds. When I change the variables to: @DATE_RANGE_START1 as datetime, @DATE_RANGE_END1 as datetime,
8
2792
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table, I have a where clause which states : where PermitID like @WorkType order by WorkStart DESC
0
7653
MMcCarthy
by: MMcCarthy | last post by:
Rather than using the Access design view change the view to SQL. I am going to attempt to outline the general syntax used for SQL queries in Access. Angle brackets <> are used in place of some syntax elements you must supply. The description of these elements will be in the contained in the angle brackets. Square brackets are used to show...
6
2933
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
0
7886
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7920
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8183
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6569
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5685
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.