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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 a way to get the value of a field

Author  Topic 

pinoyextacy
Starting Member

15 Posts

Posted - 2008-07-14 : 16:10:53
In foxpro I can write a command called val(fieldname) to get the value of the field. I was wondering in sql if their is a similar command

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-14 : 16:17:09
Just return the data:

SELECT Column1 FROM Table1 WHERE ...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-14 : 16:24:33
Are you trying to convert a string that looks like a number into a number?

Then you need CAST ot CONVERT
SELECT CONVERT(int,Col1) from yourtable

Jim
Go to Top of Page

pinoyextacy
Starting Member

15 Posts

Posted - 2008-07-14 : 17:32:17
let me rephrase that for example:
the caommand val() changes the value in a field like val(0004) to return me the value 4 instead of the 0's in front.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-14 : 17:33:54
Why don't you just change the column's data type to int then?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-14 : 17:57:33
My query will work, but everything in that column must be convertible to a number, or it will fail.

Jim
Go to Top of Page
   

- Advertisement -