Subscribe to Subscribers

Online Members

Shine S
More...

Forums » .NET » SQL Server »

Doubt in stored procedure


Posted Date: 20 Mar 2009      Posted By:: Maheswari     Member Level: Silver    Member Rank: 0     Points: 1   Responses: 6



Hi,

I got this error,

Syntax error converting the varchar value
'select distinct(a.task_id),a.tsk_desc,b.description,d.remarks,null,a.tsk_esc_dt,a.tsk_status,a.tsk_category,c.tsk_swm_id,c.tsk_swm_type from task a, trequestinfo b,tasktype c, trfdstatushistory d
where a.sub_task_id=0
and a.task_id=c.task_id
and a.sys...

What is this error?..............




Responses

#357703    Author: Babu Akkandi      Member Level: Gold      Member Rank: 48     Date: 20/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi,

Check your Where Condition,

Ensure you Comparing the columns are same dataType.

If not, conevert it, then compare.

This problem is related to data conversion.

There are two categories of data type conversions:

* Implicit conversions are invisible to the user.

* Explicit conversions use the CAST or CONVERT functions.

When you run your query = 1 , SQL implicitly converts expected results to be integers . That's why ='1' will tell SQL not to implicitly convert 1 to int , but interpret it as string.

The table of conversion types can be foung in MSDN Documentation "CAST and CONVERT".

Hope it Helps!

Thanks and Regards,
Babu Akkandi
Microsoft Technology


 
#357704    Author: D.Jeya kumar(JK)      Member Level: Gold      Member Rank: 12     Date: 20/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi,

Where is the error. which line it shows error. please post your complete query.

Regards
JK

Thanks & Regards
D.Jeya Kumar(JK)


 
#357707    Author: Maheswari      Member Level: Silver      Member Rank: 0     Date: 20/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi,

select distinct(a.task_id),a.tsk_desc,b.description,d.remarks,null,a.tsk_esc_dt,a.tsk_status,a.tsk_category,c.tsk_swm_id,c.tsk_swm_type from task a, trequestinfo b,tasktype c, trfdstatushistory d
where a.sub_task_id=0
and a.task_id=c.task_id
Error--- > and a.system_id='+@system_id+'
and a.system_id=c.system_id
and b.rfdid=c.tsk_swm_id
and d.rfdid=c.tsk_swm_id
and d.historyid in(select max(HistoryId) from trfdstatushistory where rfdid=c.tsk_swm_id)
and b.systemid='+@system_no+''





 
#357712    Author: D.Jeya kumar(JK)      Member Level: Gold      Member Rank: 12     Date: 20/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi mahe,

Systemid is a Interger or Varchar in DB?

Error--- > and a.system_id='+@system_id+'
and a.system_id=c.system_id
and b.systemid='+@system_no+''

here you had given the parameter as @system_no in another place it is

@system_id

which paramter is correct check it out...

Regards
JK

Thanks & Regards
D.Jeya Kumar(JK)


 
#357716    Author: Maheswari      Member Level: Silver      Member Rank: 0     Date: 20/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi,

I pass two parameters, system_id and system_no.

system_id is varchar
system_no is integer.

I used more than one tables. In second table, systemid is integer. so, i given to system_no.

Regards,
Maheswari


 
#357756    Author: Antony Michael Prakash      Member Level: Gold      Member Rank: 1256     Date: 20/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi

select distinct(a.task_id),a.tsk_desc,b.description,d.remarks,null,a.tsk_esc_dt,a.tsk_status,a.tsk_category,c.tsk_swm_id,c.tsk_swm_type from task a, trequestinfo b,tasktype c, trfdstatushistory d
where a.sub_task_id=0
and a.task_id=c.task_id
Error--- > and a.system_id='+@system_id+'
and a.system_id=c.system_id
and b.rfdid=c.tsk_swm_id
and d.rfdid=c.tsk_swm_id
and d.historyid in(select max(HistoryId) from trfdstatushistory where rfdid=c.tsk_swm_id)
and b.systemid='+@system_no+''


what u declare @system_id

do like this

select distinct(a.task_id),a.tsk_desc,b.description,d.remarks,null,a.tsk_esc_dt,a.tsk_status,a.tsk_category,c.tsk_swm_id,c.tsk_swm_type from task a, trequestinfo b,tasktype c, trfdstatushistory d
where a.sub_task_id=0
and a.task_id=c.task_id
Error--- > and a.system_id='+convert(int,@system_id)+'
and a.system_id=c.system_id
and b.rfdid=c.tsk_swm_id
and d.rfdid=c.tsk_swm_id
and d.historyid in(select max(HistoryId) from trfdstatushistory where rfdid=c.tsk_swm_id)
and b.systemid='+@system_no+''


regards
J. Antony Michael


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Check whether no record for join condion
Previous : Edit and update using gridview without datasource control
Return to Discussion Forum
Post New Message
Category:

Related Messages

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2013 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.