Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
error while casting a column name
error while casting a column name
Rate Topic
Display Mode
Topic Options
Author
Message
ALI100
ALI100
Posted Wednesday, February 06, 2013 11:37 PM
Grasshopper
Group: General Forum Members
Last Login: Today @ 3:35 AM
Points: 11,
Visits: 109
Set FormattedValue = CASE
When rg.ReferredFieldType='NUM'
Then CAST(#PointedMslValues.Value AS NUMERIC(18,cAST(rg.ReferredDecimalPoints) )
more cases .
END
I am generating a dynamic query which is giving error actually it requires integer value while casting not a column name
Post #1416819
nishantcomp2512
nishantcomp2512
Posted Thursday, February 07, 2013 12:56 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 2:31 AM
Points: 3,
Visits: 246
Can you able to say what is type of FormattedValue column.
FormattedValue column strict to type so you can not assign other type except type of FormattedValue column.
Thanks,
Nishant
ID:nishantcomp2512
Post #1416841
demonfox
demonfox
Posted Thursday, February 07, 2013 1:19 AM
Ten Centuries
Group: General Forum Members
Last Login: Saturday, May 18, 2013 6:46 PM
Points: 1,074,
Visits: 1,076
ALI100 (2/6/2013)
Set FormattedValue = CASE
When rg.ReferredFieldType='NUM'
Then CAST(#PointedMslValues.Value AS NUMERIC(18,cAST(rg.ReferredDecimalPoints) )
more cases .
END
I am generating a dynamic query which is giving error actually it requires integer value while casting not a column name
If you are creating a dynmaic query then try the output be like NUMERIC (18,9) ..so use concatenation of strings..
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one
Post #1416855
ChrisM@Work
ChrisM@Work
Posted Thursday, February 07, 2013 1:23 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 8:51 AM
Points: 5,608,
Visits: 10,970
ALI100 (2/6/2013)
Set FormattedValue = CASE
When rg.ReferredFieldType='NUM'
Then CAST(#PointedMslValues.Value AS NUMERIC(18,
cAST(rg.ReferredDecimalPoints)
)
more cases .
END
I am generating a dynamic query which is giving error actually it requires integer value while casting not a column name
CAST(rg.ReferredDecimalPoints AS datatype)
However, it's unlikely to be as simple as this because it will have to be stringified to work. Can you post the whole query?
“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.”
- Gail Shaw
For fast, accurate and documented assistance in answering your questions, please read
this article
.
Understanding and using APPLY, (I)
and
(II)
Paul White
Hidden RBAR: Triangular Joins
/
The "Numbers" or "Tally" Table: What it is and how it replaces a loop
Jeff Moden
Exploring Recursive CTEs by Example
Dwain Camps
Post #1416856
ALI100
ALI100
Posted Thursday, February 07, 2013 1:42 AM
Grasshopper
Group: General Forum Members
Last Login: Today @ 3:35 AM
Points: 11,
Visits: 109
FormattedValue VARCHAR(MAX)
Post #1416875
nishantcomp2512
nishantcomp2512
Posted Thursday, February 07, 2013 5:29 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 2:31 AM
Points: 3,
Visits: 246
Thanks Grasshopper for quick reply.
you can not use cAST(rg.ReferredDecimalPoints) to add decimal point to numeric data type.you can not use variable inside numeric bracket.you have to pass static value.
you can accomplish this by Substring function in sql.select only few char after decimal point from varchar data.
i thinks to pick only few char after decimal point is easy that casting to impossible numeric type as we want data should be in varchar.
Nishant
ID:nishantcomp2512
Post #1416993
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.