Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to cast from varchar to int

Author  Topic 

baska123
Yak Posting Veteran

64 Posts

Posted - 2006-09-07 : 18:38:11
What do I do wrong?

res_name = select Res_Name from MSP_WEB_RESOURCES where wRes_Id =wres_id_mgr and wres_id_mgr = cast('@ResourceName' as int)

Wres_id is int and @ResourceName' is varchar which will chave values 1,2,3.....

nathans
Aged Yak Warrior

938 Posts

Posted - 2006-09-07 : 18:43:19
You are trying to cast the char value '@ResourceName' to a integer... if the value of that parameter is an integer (meaning, a number: not a comma separated list of numbers, not numbers with letters, etc.) you need to do this:

cast(@ResourceName as int) 



with no quotes.

Make sense?

Nathan Skerl
Go to Top of Page
   

- Advertisement -