Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I convert a data-type with a select statement?
Message
From
26/07/2001 12:12:11
Guy Pardoe
Pardoe Development Corporation
Peterborough, New Hampshire, United States
 
 
To
25/07/2001 21:10:50
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00535349
Message ID:
00535826
Views:
14
Hi Sylvain,

I feel like an idiot. I had created a few sample records in SQL Server and inadvertantly copied the same numeric value into each record.

Thanks,
Guy



>Guy,
>
>Maybe you should post some code, because it works perfectly for me. Here's my test code:
>
>
create table #test (myint int identity)
>
>insert into #test default values
>insert into #test default values
>insert into #test default values
>
>select 'Test' + CAST(MyInt AS CHAR(1)) as MyField FROM #Test
>
>drop table #test
>
>The result is:
>
>
MyField
>-------
>Test1
>Test2
>Test3
>
>
>>In VFP I can combine/convert data types within a select statement like so:
>>
>
> SELECT "test" + ALLTRIM(STR(myintegerfield)) AS MyField ;
> FROM mytable
>
>>
>>If I have three rows and the values of myintegerfield were 1,2,& 3 respectively, the results would be:
>> test1
>> test2
>> test3
>>
>>
>>In TRANSACT-SQL I have tried CAST and CONVERT to accomplish the same thing but the results always come back as:
>> test1
>> test1
>> test1
>>
>>SQL Server (7.0) is only converting the numeric field once instead of for each row like VFP does.
>>
>>How can I make this work in SQL Server?
>>
>>Thanks,
>>Guy
Previous
Reply
Map
View

Click here to load this message in the networking platform