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.
| Author |
Topic |
|
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2005-06-20 : 14:35:53
|
| Hi,I need help in following query. I am try to give precision and scale for decimal value in a dynamic query.DECLARE @P AS intDECLARE @S AS intSET @P = 3SET @S = 0exec('SELECT CONVERT(DECIMAL(' +cast( @P as varchar) + ',' + cast(@S as varchar) + '), RTRIM(LTRIM(''123.3'')))')I am getting "Incorrect syntax near 'cast'" error.Any help is appreciatedthanks |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-06-20 : 14:40:50
|
try building the string first:DECLARE @P AS intDECLARE @S AS intSET @P = 3SET @S = 0Declare @sqlStr nvarchar(1000)Select @sqlStr = 'SELECT CONVERT(DECIMAL(' +cast( @P as varchar) + ',' + cast(@S as varchar) + '), RTRIM(LTRIM(''123.3'')))'exec(@sqlStr)Corey Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now." |
 |
|
|
|
|
|