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
 General SQL Server Forums
 New to SQL Server Programming
 how to update in this scenario?

Author  Topic 

allan8964
Posting Yak Master

249 Posts

Posted - 2012-09-24 : 13:23:51
Hi there,

I have a table which has a field 'Code'. Code has text of 'http:// ...' Now I want to replace http:// to https:// and I tried to use

Update table1
Set Code = Replace(Code, 'http', 'https')


I got error from this. Then what should I do for this?

Thanks in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-24 : 13:26:38
the statement looks fine. what was the error you got?


to make it more specific you can tweak it like

Update table1
Set Code = Replace(Code, 'http://', 'https://')


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

Go to Top of Page

allan8964
Posting Yak Master

249 Posts

Posted - 2012-09-24 : 13:31:05
Thanks visakh16 for quick reply!
Error is 'Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-24 : 13:37:08
nope the error has no relation to statement you posted!

post us full query. the error is due to some other query involved in the batch

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

Go to Top of Page

allan8964
Posting Yak Master

249 Posts

Posted - 2012-09-24 : 13:44:29
I exported table1 to table2 and updaye table2 it worked. I checked table1 script found difference from tabtle2 is as follows:

CONSTRAINT [PK_Site] PRIMARY KEY CLUSTERED
(
[SiteId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

any of this blocked the operation?
Thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-24 : 15:31:40
sorry whatever you're telling doesnt make any sense

the above error has nothing to do with blocking

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

Go to Top of Page
   

- Advertisement -