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)
 mid in sql

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-03-27 : 02:27:34
how can i do the following in sql

if left(destination,1)="0" then
if cint(mid(destination,2,1))>1 then
destination="0044" & mid(destination,2,ldestination-1)
end if
end if

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-27 : 02:28:36
SUBSTRING(Destionation, 2, 1)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-27 : 02:30:02
But you should really use

IF @Destination LIKE '0[2-9]%'
SET @Destination = '0044' + SUBSTRING(@Destination, 2, 8000)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-27 : 02:31:04
Or

UPDATE Table1
SET Destination = '0044' + SUBSTRING(Destination, 2, 8000)
WHERE Destination LIKE '0[2-9]%'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -