Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL equivalent of VAL function of Access

Status
Not open for further replies.

asimasm

Programmer
Nov 27, 2000
62
AU
Hi
Can any body tell me wt's the Access Val() function in T-SQL. Like there is a str() funtion but i can'r find a val() function. Plz mention any other solution aprt from Cast and Convert functions.

Thanks
 
As such there is no function under SQL 7 which duplicates the val() function, If you need to find a Numeric value in a string then u can use
CHARINDEX to find the starting position of the numeric value in a string and use SUBSTRING to retrieve one value at a time.

sorry i don't have SQL code right now, but here is a java script that i wrote to check numbers in a field. U can use the same logic if you want to!

function numcheck(num)
{
var checkok="0123456789";
var numcheck=num;
var numvalid=true;
var ch="";


for (i=0; i < numcheck.length; i++)
{
ch=numcheck.charAt(i)
for (j=0; j < checkok.length; j++)
{
if (ch==checkok.charAt(j))
break;
}

if (j==checkok.length)
{
numvalid=false;
break;
}
}
return numvalid;
}

dbtech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top