|
|
 |
| SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Language section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

November 3rd, 2009, 10:29 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Implicit conversion error on Alter Column?
I have code that generates the following SQL statement:
ALTER TABLE SurveyResults598 ALTER COLUMN Q13810 REAL
Q13810 is currently defined as a DATETIME column. I accept that data is likely to be lost or rendered useless but I still need to change the column from a DATETIME type to a REAL type. When I run it, I get this error:
Implicit conversion from data type datetime to real is not allowed. Use the CONVERT function to run this query.
Note that I am able to successfully convert REAL to DATETIME without causing this error. And I can go both directions between VARCHAR and REAL. Only DATETIME to REAL is causing this.
So, how do I specify a conversion such as this error suggests to change a column DATA TYPE from DATETIME to REAL?
|

November 3rd, 2009, 01:14 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 Posts
|
|
Since your data will become useless, isn't easier (and probably cheaper) to just delete that collumn and create a new one????
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|

November 3rd, 2009, 01:50 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, but a simple Alter Column works 99% of the time. Writing work-around code to drop and then rebuild columns for this one circumstance doesn't sound easier to me. Of course, if there's no other option then I'll have to go that route, but if it's possible to add a "Convert" clause or whatever to the existing Alter Column so that SQL server doesn't puke as it does currently, I'd prefer to go that route. I just do not know enough about SQL to know how to correct whatever is causing this error the "SQL way."
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |