How To Declare Type Varchar In Markup For SQLDataSource?

Dec 11, 2005

How do you set the type to varChar like this using markup (xml tags in the .aspx page)?

If I were creating a SQLDataSource control declaratively and one of the parameters needed to be set to VarChar rather than just a string I would set a parameter type to varchar using this syntax:  myAdapter.UpdateCommand.Paramters.Add("@Title", SqlDbType.VarChar, 80, "Title");

SQLDataSource control as a default will create parameters as strings even though the table it is pointing to has type varchar  in it such as below:


<
asp
:
Parameter

Name
="Title"
Type
="String"
/>


If I leave it like that, I get the following error below (as expected) since it really needs to be type
SqlDbType.VarChar

"The data types text and nvarchar are incompatible in the equal to operator"


Below is example default markup the SqlDataSource control creates with an update.  Where in this markup should I change things so it will update correctly to varchar rather than just trying to throw a string in the table?


<
asp
:
SqlDataSource

ID
="IISLearning_Content_SqlDataSource"

runat
="server"

ConnectionString
="
<%$ ConnectionStrings:IISLearningConnectionString %>
"


SelectCommand
=""></
asp
:
SqlDataSource
>


<
asp
:
SqlDataSource

ID
="MySqlDataSource"

runat
="server"

ConflictDetection
="CompareAllValues"


ConnectionString
="<%$ ConnectionStrings:MyConnectionString %>"
OldValuesParameterFormatString
="original_{0}"
SelectCommand
="SELECT * FROM [MyTable]"


UpdateCommand
="UPDATE [MyTable] SET [Title] = @Title  WHERE [ID] = @original_ID AND [Title] = @original_Title">

<
UpdateParameters
>


<
asp
:
Parameter

Name
="Title"
Type
="String" />


<
asp
:
Parameter

Name
="original_ID"
Type
="Int32" />


<
asp
:
Parameter

Name
="original_Title"
Type
="String" />


</
UpdateParameters
>

</
asp
:
SqlDataSource
>

 
 

 

View 2 Replies


ADVERTISEMENT

How To Declare A Procedure Parameter Type To Match A Referenced Table Colum Type

Dec 14, 2007

I like to define my procedure parameter type to match a referenced table colum type,
similar to PL/SQL "table.column%type" notation.
That way, when the table column is changes, I would not have to change my stored proc.
Any suggestion?

View 1 Replies View Related

Just Want To Make Sure (declare Data Type)

Oct 22, 2007

I've reviewed the books on line looking to see if SQL Server 2005 would now include a feature that Oracle has for years. When you declare a variable in a procedure, function, etc you can declare them as a particular table and column type. Example:

DECLARE
@GHDEP2_SSNDEPENDENTID GHDEP2.SSNDEPENDENTID%TYPE;
@GHDEP2_SSNDEPENDENTID1 GHDEP2.SSNDEPENDENTID%TYPE;

ghdep2 is the table and ssndependentid is the column. This is great because I'll never run in to a truncation issue as the variable will always be whatever the table is. This may slow things down a bit doing that sort of check but I don't care.

I just want to confirm that I can't do this in SQL 2005. All signs point to no.

View 5 Replies View Related

SqlDataSource.Select Error: Unable To Cast Object Of Type 'System.Data.DataView' To Type 'System.String'.

Oct 19, 2006

I am trying to put the data from a field in my database into a row in a table using the SQLDataSource.Select statement. I am using the following code: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'" myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)But when I run the code, I get the following error:Server Error in '/YorZap' Application. Unable to cast object of type 'System.Data.DataView' to type 'System.String'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.Source Error: Line 54: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'"
Line 55: 'myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments).GetEnumerator.Current, String)
Line 56: myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)
Line 57:
Line 58: filesTable.Rows.Add(myDataRow)Source File: D:YorZapdir_list_sort.aspx    Line: 56 Stack Trace: [InvalidCastException: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.]
ASP.dir_list_sort_aspx.BindFileDataToGrid(String strSortField) in D:YorZapdir_list_sort.aspx:56
ASP.dir_list_sort_aspx.Page_Load(Object sender, EventArgs e) in D:YorZapdir_list_sort.aspx:7
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3743
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210 Please help me!

View 3 Replies View Related

What Is The Prefered Datatype To Store HTML Markup

Oct 15, 2007

I need to store HTML markup in my database. Is there a prefered datatype to store this? Some of them could be quite long.

View 2 Replies View Related

Varchar Type

Aug 23, 2004

hi,
I want to order my varchar from alphanumeric to numeric
ex : ABCD....Z0123456789..
rather than
0123456789...ABCD..Z

for one session.

How can i do this.
There is a database parameter to do that ?

View 2 Replies View Related

Sum Of A Field That Has A Type Varchar

Mar 28, 2007

Hi guys
        I need immediate help with a query that I am trying to write. I want to sum the values in a query but the field has a type of varchar and it has decimal numbers too. So if I do the query something like that, that converts the field to int, I get the error message.
I tried converting it into real or float but I get error message on that too. I need help with adding the calculatedValues and getting there sum. I would appreciate any help with that.
 
Thanks
-Sarah
Select SUM(Convert(int, calculatedValue))
from monitor.dbo.monHistory
where LocalTimeWithoutDst > '8/26/06' and LocalTimeWithoutDst < '8/28/06'
 
This is the error message I recieve:
Conversion failed when converting the varchar value '274.2' to data type int.
 

View 6 Replies View Related

Varchar Data Type

Dec 10, 2007

Can i still get the sum of a field even if the data type is of type varchar?

thanks!

Funnyfrog

View 9 Replies View Related

Data Type Varchar And Text

Oct 27, 2007

I encounter this particular error.
Exception Details: System.Data.SqlClient.SqlException: The data types varchar and text are incompatible in the equal to operator.
Line 21:             Dim reader As SqlDataReader = command.ExecuteReader() 
This is the first time I'm trying out with MS SQL so I'm abit lost. I hope my code is correct and I've did a little search. I did not set "Text" in my database, I use int and varchar. Here's the affected part of my code and the database. Dim password As String = ""
Dim querystring As String = "SELECT Password FROM Member WHERE Username = @username"

'Dim conn as SqlConnection
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("mainconnect").ConnectionString)
Dim command As New SqlCommand(querystring, conn)
command.Parameters.Add("@username", SqlDbType.Text)
command.Parameters("@username").Value = txtLogin.Text
conn.Open()

Dim reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
password = reader("Password").ToString()
End While

reader.Close()

End Using
 
My database:
User_ID int(4)
Username varchar(50)
Password varchar(255)
Email varchar(50)
 
Any ideas?

View 2 Replies View Related

HOw To Order Fields Of Type Varchar?

Mar 22, 2000

I have a varchar field which holds IDs like (1, 3, 5, 19, 23) when I order it, i get it ordered in ASCII order like (1, 19, 23, 3, 5) rather than (1, 3, 5, 19, 23) Even if I convert it to int, I won't be able to order it.

is there any way I can order a varchar field numerically?

Angel

View 1 Replies View Related

Convert Varchar To Money Type

Mar 10, 2006

I write using the SQL ODBC driver from software into a SLQ table called UPSSHIPMENT the format is as followed:
JobNumber varchar 50
Weight real 4
FreightCost varchar 8
TrackingNumber varchar 50
Shipmethod varchar 50
VOIDID varchar 3

I then have a trigger set to update the PACKAGE table as followed
CREATE TRIGGER [UPS] ON dbo.UPSSHIPMENT
FOR INSERT

AS

BEGIN
UPDATE PACKAGE
SET WEIGHT = inserted.WEIGHT,
FREIGHTCOST = inserted.FREIGHTCOST,
TRACKINGNUMBER = inserted.TRACKINGNUMBER,
COMMENTS = inserted.SHIPMETHOD
FROM PACKAGE
INNER JOIN inserted on PACKAGE.JOBNUMBER = inserted.JOBNUMBER
WHERE inserted.VOIDID = 'N'

UPDATE PACKAGE
SET WEIGHT = '',
FREIGHTCOST = '0.00',
TRACKINGNUMBER = '',
COMMENTS = 'UPS VOID'
FROM PACKAGE
INNER JOIN inserted on PACKAGE.JOBNUMBER = inserted.JOBNUMBER
WHERE inserted.VOIDID = 'Y'

END

The format of the PACKAGE table is as followed
Jobnumber varchar 50
FreightCost money 8
TrackingNumber varchar 50
Comments varchar 2000
Weight real 4

I am getting the following error
---------------------------
Microsoft SQL-DMO (ODBC SQLState: 42000)
---------------------------
Error 260: Disallowed implicit conversion from data type varchar to data type money, table 'TESTing.dbo.Package', column 'FreightCost'. Use the CONVERT function to run this query.
---------------------------
OK
---------------------------

How do you use the convert function to change the data before the update? Thank You!
:mad:

View 6 Replies View Related

Varchar Data Type Issue

Oct 26, 2004

I am parsing a documnet and i am grabbing that document into a variable of datatype varchar. The document contains more than 8k(upto 30k characters) characters. So how can I handle this situation.How can I get that document into my local varchar variable.

thanks.

View 1 Replies View Related

How To Convert Varchar Type To Integer

Sep 19, 2014

SQL command ....

declare @found int;
set @found = 'select sid from StickyContent where StickyId='+0+' and UserId='+171
exec (@found)
delete from StickyContent where sid = @found

I need to pass this statement from my UI i.e in a single query. I am getting this error.

"Conversion failed when converting the varchar value 'select sid from StickyContent where StickyId=' to data type int.
"

View 2 Replies View Related

How To Convert Image Type To Varchar (max)

Jul 12, 2011

A table contains image type data. Actually it is text file. I don't know how to convert it to text and display. The image data size is about 20kb.

View 8 Replies View Related

It Can't Convert Varchar To A Datetime Type

Dec 14, 2007

I have this procedure and it can't convert this date to datetime type:

Exec scnr.prc_tblScannersReemplazarClasificacion
'CERVEZA ',
'CERVEZA',
'ENV VAC ',
'ENVASE VACIO',
'NULL',
'NO aplica',
'NULL',
'NO aplica',
'1-8-2007',
'10-12-2007',
'ISCRacajina';

and after that i tried to execute it, but I changed the date like next:

Exec scnr.prc_tblScannersReemplazarClasificacion
'CERVEZA ',
'CERVEZA',
'ENV VAC ',
'ENVASE VACIO',
'NULL',
'NO aplica',
'NULL',
'NO aplica',
'8-1-2007',
'12-10-2007',
'ISCRacajina';

and the procedure reseive this parameter:

CREATE PROCEDURE scnr.prc_tblScannersReemplazarClasificacion(@tipoclasificacion varchar(200),
@categoriaV varchar(200),
@categoriaN varchar(200),
@subcategoriaV varchar(200),
@subcategoriaN varchar(200),
@tipoV varchar(200),
@tipoN varchar(200),
@subtipoV varchar(200),
@subtipoN varchar(200),
@fechascanner datetime,
@fechaingreso datetime,
@usuarioscanner varchar(200) )


The error is:
Msg 8114, Level 16, State 5, Procedure prc_tblScannersReemplazarClasificacion, Line 0
Error converting data type varchar to datetime.

Why can't this procedure reseive these dates?
What can I do?

Help me...

View 3 Replies View Related

Type Casting Varchar As Time

Apr 16, 2007

Hi.



Current development setup: Visual Studio 2005 (C# language), SQL Server 2005 Express Edition.



I am at this point changing some of my application. It stores a lot of information for times of trains. I decode a file which is text based and my times are stored in varchar(4) columns with the format "HHmm".



I am now at a stage where I need to add values to these times and perform a search based on two time values (a minimum time and maximum time).



I really need to be able to add another varchar(4) value to the times stored in my database (also varchar(4) - may look at this again in future). I have absolutely no interest in storing seconds, modifying the database to include the time colon, nor am I interested in the date portion of a time string, only the 4 digits representing the hours and minutes.



Can this be done easily in SQL server? For example:



varchar(4) of 0445 + varchar(4) of 0027 should result in the time 0512.



Similarly a varchar(4) of 2358 + varchar(4) of 0015 should result in the time 0013.



This has to be very quick to execute.



Thanks for any help you can offer!



Sean



View 1 Replies View Related

Error Converting Data Type Varchar To Int.

Oct 9, 2007

can anyone see as to why I would get this error with the following SP?
 ALTER PROCEDURE [dbo].[SP]
@ID int = 0,
@emailFrom VARCHAR(50) = Null,
@emailDate VARCHAR(50) = Null,
@emailSubj VARCHAR(50) = Null,
@emailTxtBody VARCHAR(1000) = Null,
@emailHtmlBody VARCHAR(1000) = Null

AS
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @Notes VARCHAR (8000)
DECLARE @TicketID INT
DECLARE @emailBody VARCHAR (1000)
DECLARE @Length Int

SET @Notes = ''
SET @Length = LEN(@emailSubj)

-- insert a new entry
INSERT INTO PopEmail
( emailFrom, emailDate, emailSubj, emailTxtBody, emailHtmlBody )
VALUES
( @emailFrom, @emailDate, @emailSubj, @emailTxtBody, @emailHtmlBody )
-- get the new ID
SET @ID = @@identity

If ( @ID <> 0 ) AND ( ISNUMERIC(@emailSubj) = 1 )

Begin
IF @emailTxtBody IS NULL
BEGIN
Set @emailBody = @emailHtmlBody
PRINT '@emailHtmlBody: ' + @emailBody
END

ELSE

BEGIN
SET @emailBody = @emailTxtBody
PRINT '@emailTxtBody: ' + @emailBody
END

SET @TicketID = CAST( @emailSubj AS int )
SET @Notes = @emailFrom + ', ' + @emailDate + ', ' + @emailBody
Select @ID = ID From TicketDetails Where TicketDetails.TicketID = @TicketID

Exec differentSP @ID, @TicketID, @Notes

PRINT 'Subject: [' + @emailSubj + ']'
print 'length: ' + CAST(@Length as varchar (10))
Print 'emailSubj: ' + CAST( @emailSubj AS int )
PRINT 'ID: ' + Cast( @ID as varchar ( 10 ) )
PRINT 'TicketID: ' + Cast( @TicketID AS Varchar ( 10 ) )
PRINT 'Notes: ' + @Notes
PRINT 'ID: ' + Cast( @ID as varchar ( 10 ) )
END
ELSE

BEGIN
Print 'ID: ' + CAST(@ID AS VarChar(10))
PRINT 'ISNUMERIC: ' + CAST(ISNUMERIC(@emailSubj) AS VarChar (10))
PRINT 'Subject: [' + @emailSubj + ']'
END 

View 2 Replies View Related

Error Converting Data Type Varchar To Int

Mar 11, 2000

I have a table with a column (locationID) of int data type, I want to pass a list of locationID's to a stored procedure using the IN operator (e.g. WHERE LocationID IN (list of locationID's)). What can I do to achieve this????

My stored procedure looks like this:

CREATE PROCEDURE [sp_test]
@sLocIDs varchar(30)
AS
select count(distinct TimeZoneID) As timezones,
from dimLocation
WHERE LocationID IN (@sLocIDs)

When I test it:
exec sp_test
@sLocIDs = '1,2,10'
I get "Error converting data type varchar to int"

View 1 Replies View Related

How To Get Month And Year From A Date Which Is Of Type Varchar(20)

Dec 2, 2011

In my table I am using varchar to save a date like this 2-dec-2011. Now I have a requirement where i need to select employee who where present in a month so for that I need a query so that i can pull out all the employees who are present in dec like :

Code:
select * from emp_attendence where date = 'dec-2011'

But this returns nothing ...

View 8 Replies View Related

Converting Data Type Varchar To Numeric

Feb 2, 2013

when i execute my store procedure it give this error.

USE [CWMNEW]
GO
DECLARE@return_value int
EXEC@return_value = [dbo].[BOQ]
SELECT'Return Value' = @return_value
GO

[code]....

View 1 Replies View Related

Searching For Dates In A Column Of Type Varchar

Feb 22, 2008



I have a DB named zCIFRecord with a column named CIFUpdateDate which is of datatype varchar. The data is a date MM/DD/YYYY 01/30/2008, this is al that is in this column. I can search this colum for individual dates and for a range of dates. My problem is with a range of dates that is not within the same year, such as;


SELECT [CIFPan]

,[CIFMemNum]

,[CIFLName]

,[CIFFName]

FROM [FutureSoft].[dbo].[zCIFRecord]

WHERE [CIFUpdateDate] between '12/01/2007' and '01/30/2008'


will return nothing because it seems to only search on the 12 then the 01 then the 2008. this search can be performed properly on dates within the same year such as;

SELECT [CIFPan]

,[CIFMemNum]

,[CIFLName]

,[CIFFName]

FROM [FutureSoft].[dbo].[zCIFRecord]

WHERE [CIFUpdateDate] between '01/01/2008' and '01/30/2008'

will return the proper values because now all the numbers are in correct order. How can i create a search that lets me perform the first query as well as the second query. I tried to convert to a float but you cant convert a varchar to a float.

View 17 Replies View Related

Data Type Conversion .. Varchar To GUID

Jul 31, 2006

Hi,

I have a parameter @name varchar(50)

but the table has a field with datatype GUID

how I can convert varchar to guid before insertion...

Thanks

View 1 Replies View Related

Encrypted Value Shown As '??????' In A Column Of Type Varchar

Jun 2, 2006

Dear All,

I inserted a record in table on DB created on SQLServer 2005 and found out that the one of the column values is shown as '??????' instead of showing the encrypted value that I sent with the insert statement.3



............................ Can anyone tell me how to get rid of this?

Thanks and regards,



Z Z.

View 5 Replies View Related

SqlDataSource Using A Type Parameter Of Table

Oct 8, 2006

I am not sure (and I've been known to overlook things) if it is possible to use a Table parameter type as parameter to a stored procedure?  Is it possible? I would prefer not to create a SQL batch statement calling an stored proc w/ one parameter over and over. Instead i'd rather just create the stored proc to take a table parameter and pass the table into the stored proc.  I know I could use a CSV string of IDs instead of a table...  or I could create a big SQL batch and use that.  But I'd rather not. Could anyone provide some guidance? Thanks!Joe

View 2 Replies View Related

Error Converting Data Type Varchar To Datetime.

Feb 16, 2007

Hi,
It is not exactly what I stated in the subject - It's an outcome - exception thrown while executing non-query command.
I get this exception when I try to execute my stored procedure that takes datetime as one of its parameters.
I am using dataset designer to create table adapters and build queries. Then I simply use objectdatasource component that uses one of the table adapters and bind it to for example a detailsview control.
When I run this in debug mode and trace the objects everything looks perfect including these datetime parameters. It is sql server that throws the exception. I ran the sql profiler to see what exactly is going on, and I captured the command that is sent by ADO - it's broken into several lines right in the middle of my datetime parameters... this is the source of the problem. Everything is working fine when I take this command and execute it as a single line in the sql management studio.
Is there anything about ADO that I do not know?

View 2 Replies View Related

Error Converting Data Type Varchar To Bigint.

Aug 25, 2005

I have the following query which has been giving me headaches for days :  SELECT SCCode [Service Catalog Code], FileName [File Name], FullName [Full Name], FileExtension [Extension], FileSize [Size],  Author [Author], CONVERT(VARCHAR(50),CAST(LastModified AS SMALLDATETIME), 120) [Last Modified],   CONVERT(VARCHAR(50),CAST(LastAccessed AS SMALLDATETIME), 120) [Last Accessed], TimesAccessed [Downloads],  UploadedBy [Uploaded By], CONVERT(VARCHAR(50),CAST(UploadedAt AS SMALLDATETIME), 120) [Uploaded At]  FROM #TempTable  WHERE id > @firstitem AND id < @lastitem  ORDER BY   CASE  WHEN @sortcolumn = 'Service Catalog Code' THEN SCCode    WHEN @sortcolumn = 'File Name' THEN FileName    WHEN @sortcolumn = 'Extension' THEN FileExtension    WHEN @sortcolumn = 'Size' THEN FileSize    WHEN @sortcolumn = 'Author' THEN Author    WHEN @sortcolumn = 'Last Modified' THEN CONVERT(VARCHAR(50),CAST(LastModified AS SMALLDATETIME), 120)    WHEN @sortcolumn = 'Last Accessed' THEN CONVERT(VARCHAR(50),CAST(LastAccessed AS SMALLDATETIME), 120)    WHEN @sortcolumn = 'Downloads' THEN TimesAccessed    WHEN @sortcolumn = 'Uploaded By' THEN UploadedBy    WHEN @sortcolumn = 'Uploaded At' THEN CONVERT(VARCHAR(50),CAST(UploadedAt AS SMALLDATETIME), 120)   END ASCWhen my @sortcolumn parameter is either FileSize (BIGINT) or TimesAccessed (BIGINT) then the query returns the data without any problem. However, if I use a different @sortcolumn value such as "Author" then I keep getting "Error converting data type varchar to bigint."A solution that seems to work is to drop CASE and use lots of IF statements instead. I don't prefer to do this because it requires me to repeat the same select statement for each and every possible @sortcolumn value!Does anyone know how to solve this? Help!

View 2 Replies View Related

Error Converting Data Type Varchar To Datetime

Dec 4, 2004

hi
i want to pass a datetime variable from a asp page to MSSQL through a stored procedure, & i get this error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Error converting data type varchar to datetime.

this is the code that i use in page:

strsql="sp_inventory @timee=' " & RecievedDate & " ' "

also i use this one:
but i still get this error

strsql="sp_inventory @timee=' " & cdate(RecievedDate) & " ' "


this is maybe useful that i get this errot on some PCs, not all the computeres.
sometimes work well, & sth not work.

View 2 Replies View Related

Error Converting Data Type Varchar To Datetime.

Dec 22, 2004

Here is the stored procedure
the data type for the column b_trn_tentdte is decimal(8,0).

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER Procedure Prc_New_cus_wo_prev_posted
@b_trn_tendte_Beg_Date datetime
,@b_trn_tendte_End_Date datetime
@b_trn_tendte_Beg_Date1 datetime
,@b_trn_tendte_End_Date2 datetime

as

declare @Beg_tentdte datetime
declare @End_tentdte datetime
declare @Beg_tentdte1 datetime
declare @Beg_tentdte2 datetime

set @Beg_tentdte = convert(varchar(10), @b_trn_tendte_Beg_Date, 112)
set @End_tentdte = convert(varchar(10), @b_trn_tendte_End_Date, 112)
set @Beg_tentdte1 = convert(varchar(10), @b_trn_tendte_Beg_Date1, 112)
set @Beg_tentdte2 = convert(varchar(10), @b_trn_tendte_End_Date2, 112)


/* this query looks for customers with posted
transactions but none prior to the date range
in question */

Select distinct b_cus_cname
from
bar_cus_db_rec
,bar_trn_db_rec b
where b.b_trn_instid = ''
and b.b_trn_instid = b_cus_instid
and b.b_trn_actid = b_cus_cusid
and convert(varchar(10), b.b_trn_tentdte) between @Beg_tentdte and @End_tentdte
and not exists (select c.b_trn_actid
from bar_trn_db_rec c
where c.b_trn_instid = b.b_trn_instid
--and c.b_trn_tentdte between 19970901 and 20030229
and convert(varchar(10), c.b_trn_tentdte) between @Beg_tentdte1 and @Beg_tentdte2
and c.b_trn_actid = b.b_trn_actid)

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

every time I run the query, I get this error message:
Error converting data type varchar to datetime.

thanks for your assistance.

View 5 Replies View Related

Help With Error Converting Data Type Varchar To Float

Oct 17, 2007

Error converting data type varchar to float.


I am getting this error. Any one there to guide me

View 4 Replies View Related

Error Converting Data Type Varchar To Datetime

Jun 21, 2006

An application i am using creates an error.

Using SQL-profiler i catch this statement:

exec sp_executesql N'insert into RECORDING_SCHEDULE (programme_oid, capture_source_oid, filename, status, recording_group, recording_type, manual_channel_oid,
manual_start_time, manual_end_time, quality_level, pre_pad_minutes, post_pad_minutes) values (@P1,@P2,@P3,@P4,@P5,@P6,@P7,@P8,@P9,@P10,@P11,@P1 2)',N'@P1 int,@P2 int,@P3
nvarchar(19),@P4 int,@P5 int,@P6 int,@P7 int,@P8 datetime,@P9 datetime,@P10 int,@P11 int,@P12 int',177748,2,N'Lilla röda traktorn',4,40,5,16,''2006-06-21
17:00:00:000'',''2006-06-21 20:00:00:000'',1,1,2


After removing the double ' around the date and time parts i get the following error when running in QA:
Msg 8114, Level 16, State 5, Line 0
Error converting data type varchar to datetime.

If a remove the time portion it works.

The DDL for the table is:

CREATE TABLE [dbo].[RECORDING_SCHEDULE](
[oid] [int] IDENTITY(1,1) NOT NULL,
[programme_oid] [int] NULL,
[capture_source_oid] [int] NULL,
[status] [smallint] NOT NULL,
[filename] [varchar](255) NULL,
[recording_type] [int] NULL,
[recording_group] [int] NULL,
[manual_start_time] [datetime] NULL,
[manual_end_time] [datetime] NULL,
[manual_channel_oid] [int] NULL,
[quality_level] [int] NULL CONSTRAINT [DF__RECORDING__quali__38996AB5] DEFAULT ((0)),
[pre_pad_minutes] [int] NULL CONSTRAINT [DF__RECORDING__pre_p__398D8EEE] DEFAULT ((0)),
[post_pad_minutes] [int] NULL CONSTRAINT [DF__RECORDING__post___3A81B327] DEFAULT ((0)),
CONSTRAINT [aaaaaRECORDING_SCHEDULE_PK] PRIMARY KEY NONCLUSTERED

What am I missing?

View 2 Replies View Related

Error Converting Data Type Varchar To Numeric

Dec 10, 2014

I have a sql code that I am having some difficulty with. All I'm trying to do is get each department and sum the amount by month based on the date in the table. I am getting "error converting data type varchar to numeric".

Code:
select DEPARTMENT,
CASE
WHEN ((DATE >= '06/01/2014') AND (DATE <= '06/30/2014')) THEN (cast(sum(Amount) as decimal(10,2)))
ELSE '' END AS 'JUNE',
CASE
WHEN ((DATE >= '07/01/2014') AND (DATE <= '07/30/2014')) THEN (cast(sum(Amount) as decimal(10,2)))
ELSE '' END AS 'JULY'
from L27_PHAROS_DETAIL_DATA
WHERE Department = 'TECHNOLOGY SERVICES'
GROUP BY DEPARTMENT, DATE
ORDER BY DEPARTMENT

View 5 Replies View Related

Error Converting Data Type Varchar To Numeric

Jun 13, 2008

Hi Group:

I try to JOin to tables: Enterprise has a decimal(5,3) and COHIER has varchar 5. All I am getting is an error on converting data. How can I fix this problem.



SELECT a.Security_Value, b.Enterprise_Number, b.Enterprise_Description
FROM dbo.COHIER a INNER JOIN
dbo.Enterprise b ON a.Security_Value = b.Enterprise_Number


Thanks!!!!!!

View 6 Replies View Related

Convert Date Format - Data Type Varchar

Aug 6, 2013

I have a column which is

Data type : varchar(10)
Date format : 8/5/2013

I want to convert that column to the following

Data type varchar: (8)
Date format : 20130805

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved