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
 Help Please

Author  Topic 

nirene
Yak Posting Veteran

98 Posts

Posted - 2008-09-26 : 11:25:43
Hai All,

Set SQLStr='Update ' + @Tbl + ' Set ' + @FldNm + '=''' + @Junk +''''
Exec sp_executesql @SQLStr

Where @Tbl is my Table Name
@FldNm - Field name
@Junk - is the String Variable

I dont no what I'm doing wrong,please solve this.

Nirene

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-26 : 11:27:26
use EXEC(@SQLStr). no need of sp_executesql here
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-26 : 11:28:11
What is your problem?
Error?
Wrong values?
Nothing?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-26 : 11:36:45
quote:
Originally posted by nirene

Hai All,

Set SQLStr='Update ' + @Tbl + ' Set ' + @FldNm + '=''' + @Junk +''''
Exec sp_executesql @SQLStr

Where @Tbl is my Table Name
@FldNm - Field name
@Junk - is the String Variable

I dont no what I'm doing wrong,please solve this.

Nirene




SQLStr should be @SQLStr

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nirene
Yak Posting Veteran

98 Posts

Posted - 2008-09-26 : 11:50:47
Thanks Madhivanan.I was breaking my head for the past 1/2 hour for this simple work.

Thanks once again.

Nirene
Go to Top of Page
   

- Advertisement -