-
HELP!!! how to assign an int value using a string??
hi, can somebody help me to solve this problem?
first, declare 2 variables
declare @num int
declare @str varchar(255)
then set the varchar variable to '100/10'
set @str = '100/10'
is there anyway to assign a value to @num using @str, so that @num has a value 10??
set @num = @str ????????
-
HELP!!! how to assign an int value using a string?? (reply)
declare @num int
declare @str varchar(255)
declare @str1 varchar(255)
declare @str2 varchar(255)
set @str = '100/10'
set @str1 = left(@str,charindex("/",@str)-1)
set @str2 = right(@str,charindex("/",@str)-2)
set @num = convert(int,@str1) / convert(int,@str2)
print @str
print @str1
print @str2
print @num
------------
sql newbie at 5/24/2002 12:28:22 AM
hi, can somebody help me to solve this problem?
first, declare 2 variables
declare @num int
declare @str varchar(255)
then set the varchar variable to '100/10'
set @str = '100/10'
is there anyway to assign a value to @num using @str, so that @num has a value 10??
set @num = @str ????????
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|