| Author |
Topic |
|
Tricia
Starting Member
4 Posts |
Posted - 2007-05-04 : 12:35:03
|
| This is my query:SELECT convert(prospects.prospectid as int(8)) as Prospect, trialSessions.experienceCode, prospects.emailFROM trialSessions JOIN prospects ON trialSessions.prospectID = prospects.prospectidI'm getting this error message:Incorrect syntax near the keyword 'as'Can someone tell me what I'm missing :) |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-04 : 12:37:03
|
| convert(bigint, prospects.prospectid) or cast(prospects.prospectid as bigint)_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-04 : 12:37:13
|
quote: Originally posted by Tricia This is my query:SELECT cast(prospects.prospectid as int(8)) as Prospect, trialSessions.experienceCode, prospects.emailFROM trialSessions JOIN prospects ON trialSessions.prospectID = prospects.prospectidI'm getting this error message:Incorrect syntax near the keyword 'as'Can someone tell me what I'm missing :)
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Tricia
Starting Member
4 Posts |
Posted - 2007-05-04 : 12:50:10
|
| Now I'm getting this error:Conversion failed when converting the varchar value '3C1F1C44-CC6D-44F6-9077-9E4EFB8244EC' to data type int. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-04 : 13:04:16
|
you want to convert the string '3C1F1C44-CC6D-44F6-9077-9E4EFB8244EC' into integer ? KH |
 |
|
|
Tricia
Starting Member
4 Posts |
Posted - 2007-05-04 : 13:07:03
|
| What I actually want to convert this to is to a numeric but I can't seem to get this to work either as an int, varchar or numeric. I know I'm missing something but am at a loss. I really appreciate anyhelp. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-04 : 13:08:49
|
| and how do you want this conversion to work logicaly??_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-04 : 13:27:10
|
quote: but am at a loss
You are not alone there. How do you expect to convert a string like '3C1F1C44-...' to numeric ? What is this string anyway ? What is the purpose of "converting" it to numeric ? KH |
 |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-05-04 : 13:46:59
|
| How about doing it this way:SELECT CAST(CAST('3C1F1C44-CC6D-44F6-9077-9E4EFB8244EC' AS VARBINARY) AS INT)SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-05-05 : 02:10:25
|
| Am I on the wrong end of the stick here?Its a GUID, and thus could be converted to either a Uniqueidentifier, or, if you must, a 16-byte binary:SELECT CONVERT(uniqueidentifier, '3C1F1C44-CC6D-44F6-9077-9E4EFB8244EC')SELECT CONVERT(varbinary(16), CONVERT(uniqueidentifier, '3C1F1C44-CC6D-44F6-9077-9E4EFB8244EC'))Or even, maybe:SELECT CONVERT(bigint, CONVERT(varbinary(16), CONVERT(uniqueidentifier, '3C1F1C44-CC6D-44F6-9077-9E4EFB8244EC')))Kristen |
 |
|
|
|