July 8, 2003 at 9:55 am
Can I use the table data type to combine many tables with VARYING amounts of data in each table?
When I tried I either get NO data, or the wrong data
July 9, 2003 at 8:10 am
Here is kinda what I want to do....(I know this doesnt work)...can someone help me get it right..
Create function GetAllData
(@filterid uniqueidentifier)
RETURNS table
AS
RETURN {select statement that uses all the tables below )
Begin
declare @networktbl TABLE
(
filterid uniqueidentifier, network_id uniqueidentifier,
netmask char(15),gateway char(15), network_address char(15),netname char(30),
checkbit bit)
BEGIN
INSERT @networktbl
SELECT n.filterid, n.network_id, n.netmask, n.gateway,
n.network_address, n.netname,n.checkbit
From network n
where n.checkbit = 0
END
declare @addresstbl TABLE
(
filterid uniqueidentifier, host_id char(10), add_id char(10),
broadcast_src_addr char(10), broadcast_dst_addr char(10),
network_src_addr char(10), network_dst_addr char(10), checkbit bit)
BEGIN
INSERT @addresstbl
SELECT a.filterid, a.host_id, a.add_id, a.broadcast_src_addr, a.broadcast_dst_addr,
a.network_src_addr, a.network_dst_addr, a.checkbit From address a
where a.checkbit = 0
END
declare @ethernettbl TABLE
(
netadd_id uniqueidentifier, filterid uniqueidentifier, mac_src numeric(18,0),
mac_dst numeric(18,0), type char(10), version char(10), checkbit bit)
BEGIN
INSERT @ethernettbl
SELECT e.netadd_id, e.filterid, e.mac_src, e.mac_dst,e.type,
e.version, e.checkbit
From ethernet e
where e.checkbit = 0
END
declare @datatbl TABLE
(
banner char(10), filterid uniqueidentifier, data_id char(10),
payload varchar(8000), checkbit bit)
BEGIN
INSERT @datatbl
SELECT d.banner, d.filterid, d.data_id, d.payload,
d.checkbit From data d
where d.checkbit = 0
END
declare @hosttbl TABLE
(
filterid uniqueidentifier, host_id char(10),
os char(10), vender char(20), hardware_type char(20),
host_dst char(10), host_src char(10),hostname char(20),
interface char(10), device char(10), port char(10), checkbit bit)
BEGIN
INSERT @hosttbl
SELECT h.filterid, h.host_id, h.os, h.vender,h.hardware_type,
h.host_dst, h.host_src ,h.hostname,h.interface,
h.device, h.port, h.checkbit
From host h
where h.checkbit = 0
END
declare @servicetbl TABLE
(
service char(10), filterid uniqueidentifier, protocol varchar(50), port char(50),
service_id uniqueidentifier, direction varchar(50), checkbit bit)
BEGIN
INSERT @servicetbl
SELECT s.service, s.filterid, s.protocol,
s.port, s.service_id, s.direction, checkbit From services s
where s.checkbit = 0
select * from @servicetbl
RETURN
END
END
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply