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)
 LIKE statement

Author  Topic 

nhaas
Yak Posting Veteran

90 Posts

Posted - 2011-08-29 : 11:00:24
I am having trouble With a Like statement. how do i get the like to work, I am not quite sure how do get it to work.
Thanks

DECLARE @orgnum varchar(10)
DECLARE @orgnum1 varchar(10)
set @orgnum1='8-3930'
set @orgnum='83930'

UPDATE Tesisdev.dbo.TNBCompare SET status='no', ORG=
(Select BU from TESIS.DBO.Tesis2 where KEY0 LIKE @orgnum1)
WHERE Tesisdev.dbo.TNBCompare.DN = @orgnum

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-29 : 11:02:39
dont you have any relationships between two tables?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2011-08-29 : 11:28:43
NO Tesis2 table has a column KEY0 that has phone numbers like 1-1111 and TNBCompare has a column DN with numbers like 11111
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-29 : 12:29:42
[code]
UPDATE tc
SET tc.status='no', tc.ORG= t.BU
FROM Tesisdev.dbo.TNBCompare tc
INNER JOIN(Select KEY0 ,BU from TESIS.DBO.Tesis2) t
ON REPLACE(t.KEY0,'-','') = tc.DN
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2011-08-29 : 16:51:00
Worked like a charm! Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-30 : 10:03:24
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -