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
 Transact-SQL (2000)
 Select ....

Author  Topic 

Karander
Starting Member

34 Posts

Posted - 2005-09-03 : 09:02:44
Hi,
I need help, I just want to do sth like this:

select @ciag = 'update ##temp1 SET M'+cast (@id as varchar)+'='
select @ciag = @ciag + '"'+cast(@pr as varchar)+ '-'+cast (@cn as varchar)+'" where id='+cast (@post as varchar)

in result i wan to have sth like this:
update ##temp1 SET M1="23.45-56.67" where id=5

i got error: Ivalid Column name 23.45-56.67

M1 field is varchar field

please help me ....

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-03 : 10:02:40
replace " with '
select @ciag = 'update ##temp1 SET M'+cast (@id as varchar)+'='
select @ciag = @ciag + ''''+cast(@pr as varchar)+ '-'+cast (@cn as varchar)+''' where id='+cast (@post as varchar)

Go with the flow & have fun! Else fight the flow
Go to Top of Page

VIG
Yak Posting Veteran

86 Posts

Posted - 2005-09-03 : 10:05:51
[code]select @ciag = 'update ##temp1 SET M'+cast (@id as varchar)+'='
select @ciag = @ciag + '''' +cast(@pr as varchar)+ '-'+cast (@ch as varchar)+''' where id='+cast (@post as varchar)[/code]
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-09-03 : 10:09:10
EDIT:
Holy Cow!! a double

I think you just need to replace your double quote with 2 single quotes:

select @ciag = @ciag + ''''+cast(@pr as varchar)+ '-'+cast (@cn as varchar)+''' where id='+cast (@post as varchar)

so your end result should look like this:
update ##temp1 SET M1='23.45-56.67' where id=5

Be One with the Optimizer
TG
Go to Top of Page

Karander
Starting Member

34 Posts

Posted - 2005-09-03 : 12:11:45
yes it works, thank you. I have just only entered char (39) ]

Really thanks
Go to Top of Page
   

- Advertisement -