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.
| Author |
Topic |
|
John T.
Posting Yak Master
112 Posts |
Posted - 2003-04-19 : 10:40:12
|
| I am fairly new to SQL. I have a parameter passed to my Sproc that is of type varchar(50). I want to compare it with a field in my db that is SMALLINT. I have tried using a CONVERT(SMALLINT, @VARCHARVAR) and it seems to think I am trying to use a SMALLDATETIME conversion. Can this be done in SQL?Thanks. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-04-19 : 10:55:39
|
| What is actually stored in your VARCHAR's? It is just numbers and nothing else, or is there formatting or extra (non-numeric) characters in there? List out some examples of your data if you could.CONVERT(smallint, @variable)should work fine, as long as @variable has valid data.- Jeff |
 |
|
|
John T.
Posting Yak Master
112 Posts |
Posted - 2003-04-19 : 11:03:41
|
| I'll keep trying. Just record numbers. One table is char and the other is smallint. I could change design of tables to both being smallint. But just would like to see this work for learning purposes. Thanks much. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-04-19 : 14:19:09
|
| where fld = convert(smallint, @myfld)will work and won't give you a datetime error if fld is a smallint.datetime has a hogher precedence than most datatypes so if you are using a field of that type in your query it will try and implicitly convert al other fields involved in the expression t datetime and give you this error.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|