azygole
جمعه 05 اسفند 1390, 00:24 صبح
سلام
یک جدول فرمول دارم که در آن فرمولهایم را تعریف می کنم . حالا چطوری یه select روی اون بزنم که فرمولم رو اجرا کنه
drop table Formuls
go
CREATE TABLE Formuls(
ID numeric(18, 0) IDENTITY(1,1) PRIMARY KEY,
Formul nvarchar(50)
)
go
insert into Formuls values ( 'a*b' )
insert into Formuls values ( 'a*c' )
go
drop table Table1
go
CREATE TABLE Table1 (
ID numeric(18, 0) IDENTITY(1,1) PRIMARY KEY,
A numeric(18,0) ,
B numeric(18,0) ,
C numeric(18,0)
)
go
insert into Table1 values ( 2,3,4 )
insert into Table1 values ( 5,6,7 )
insert into Table1 values ( 7,8,9 )
go
drop function zarb
go
CREATE Function Zarb(@id numeric(18,0)) returns nvarchar(255) as
begin
declare @Formula nvarchar(255)
select @Formula = Formul from Formuls where ID = @id
return @Formula
end
go
select dbo.Zarb(1) , dbo.Zarb(2) result from Table1 where ID = 1
من می خوام در select آخر به جای اینکه a*b رو نمایش بده a رو در b ضرب کنه
اگه ممکنه راهنماییم کنید . با تشکر
یک جدول فرمول دارم که در آن فرمولهایم را تعریف می کنم . حالا چطوری یه select روی اون بزنم که فرمولم رو اجرا کنه
drop table Formuls
go
CREATE TABLE Formuls(
ID numeric(18, 0) IDENTITY(1,1) PRIMARY KEY,
Formul nvarchar(50)
)
go
insert into Formuls values ( 'a*b' )
insert into Formuls values ( 'a*c' )
go
drop table Table1
go
CREATE TABLE Table1 (
ID numeric(18, 0) IDENTITY(1,1) PRIMARY KEY,
A numeric(18,0) ,
B numeric(18,0) ,
C numeric(18,0)
)
go
insert into Table1 values ( 2,3,4 )
insert into Table1 values ( 5,6,7 )
insert into Table1 values ( 7,8,9 )
go
drop function zarb
go
CREATE Function Zarb(@id numeric(18,0)) returns nvarchar(255) as
begin
declare @Formula nvarchar(255)
select @Formula = Formul from Formuls where ID = @id
return @Formula
end
go
select dbo.Zarb(1) , dbo.Zarb(2) result from Table1 where ID = 1
من می خوام در select آخر به جای اینکه a*b رو نمایش بده a رو در b ضرب کنه
اگه ممکنه راهنماییم کنید . با تشکر