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
 update script for hyperlink

Author  Topic 

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-05-15 : 11:34:24
I have a table name tbl1, i have to update data on hlink field.
the following script can not run, get error.

Any body have solution?

declare @tbl1 table
(ID INT,
hlink varchar(200)
)

INSERT INTO @tbl1
SELECT 1,null

INSERT INTO @tbl1
SELECT 2,null

INSERT INTO @tbl1
SELECT 3,null

INSERT INTO @tbl1
SELECT 4,null

declare @val varchar(200)
set @val='<a href="javascript:popup(''frmInfo.aspx?ID='+ convert(varchar,ID)+')">Abc</a>'
update @tbl1 set hlink=@val

select * from @tbl1

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-05-15 : 11:54:34
declare @tbl1 table
(ID INT,
hlink varchar(200)
)

INSERT INTO @tbl1
SELECT 1,null

INSERT INTO @tbl1
SELECT 2,null

INSERT INTO @tbl1
SELECT 3,null

INSERT INTO @tbl1
SELECT 4,null

declare @val varchar(200)

update @tbl1
set hlink='<a href="javascript:popup(''frmInfo.aspx?ID='+ convert(varchar(7),ID)+')">Abc</a>'

Jim
Go to Top of Page

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-05-15 : 11:59:00
I got following error:

Msg 102, Level 15, State 1, Line 20
Incorrect syntax near '='.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-05-15 : 12:02:38
It works for me, are you sure you got everything on the copy and paste?

Jim
Go to Top of Page

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-05-15 : 12:06:57
Oh ya, its work. Thanks a lot Jim
Go to Top of Page
   

- Advertisement -