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
 SQL Server Development (2000)
 variables in where clause

Author  Topic 

hueby
Posting Yak Master

127 Posts

Posted - 2006-04-18 : 17:11:46
Hi all,

I'm playing with some WHERE statements. Below are examples of what I'm trying to do. Are these methods possible using a variable @tagno?

WHERE Item_Code = (@tagno = left(@tagno + REPLICATE(' ',15), 15))

Here it would take whatever @tagno is, and add spaces after the text to maximize 15 characters.

WHERE Item_Code LIKE @tagno + '%'

Here it would take whatever @tagno is, and allow whatever text afterwards.

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-18 : 18:21:23
WHERE Item_Code = left(@tagno + REPLICATE(' ',15), 15))

the second should work as it is.


==========================================
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.
Go to Top of Page
   

- Advertisement -