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 2005 Forums
 Transact-SQL (2005)
 Variable Syntax

Author  Topic 

cjhardie
Yak Posting Veteran

58 Posts

Posted - 2007-04-04 : 18:04:01
I want a variable in a certain spot but can't figure out how.

Here is the end of the clause

where postalcode like '01845'

I want 01845 to be the variable @postalcodename

So I wrote it like this: where postalcode like @postalcodename, but it didnt work. The problem is that postalcode is char and @postalcodename is int. Any help?
I cant make @postalcodename char because it is used more as an int type.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-04 : 18:05:42
[code]
where postalcode like convert(varchar(10), @postalcodename) + '%'
[/code]


KH

Go to Top of Page
   

- Advertisement -