0
Declare @table table
(
Col1 varchar(50),
Col2 varchar(50)
)
insert into @table
select '100', '*10+2'
select Col1 + '' + Col2
from @table
預期成果是:1002SQL服務器計算字符串值
能否請你幫忙嗎?
Declare @table table
(
Col1 varchar(50),
Col2 varchar(50)
)
insert into @table
select '100', '*10+2'
select Col1 + '' + Col2
from @table
預期成果是:1002SQL服務器計算字符串值
能否請你幫忙嗎?
使用這樣的:
Declare @table table
(
Col1 varchar(50),
Col2 varchar(50)
)
Declare @Out varchar(100),@Query varchar(100)=''
insert into @table
select '100', '*10+2'
select @Out= Col1 + '' + Col2
from @table
SET @Query = 'SELECT ' [email protected]
EXEC (@Query)
Use EXEC SQL query :
Declare @table table
(
Col1 varchar(50),
Col2 varchar(50)
)
DECLARE @Cal VARCHAR(100)
insert into @table
select '100' , '*10+2'
SELECT @Cal = Col1+''+Col2 from @table
SELECT @Cal = 'SELECT (' + @Cal + ')'
EXEC (@Cal)
你寫過任何一種解析器這個? 另外,試試這個:http://stackoverflow.com/questions/9850894/string-expression-to-be-evaluated-to-number – owczarek