如题。
1 INSERT INTO [ApplicationLog]
2 ([AppServerID],[Class],[Level])
3 VALUES(@[AppServerID],@[Class],@[Level]);
4 --其中,AppServerID的值由下面的查询得到
5 SELECT AppServerID FROM AppServerConnection
6 WHERE
7 AppID=@AppID AND ServerID=(SELECT a.ServerID FROM PCServer AS a WHERE a.IntranetIP = @IntranetIP
请问这个该怎么写成一个存储过程呀!!!谢谢!!!!
4 回答

忽然笑
TA贡献1806条经验 获得超5个赞
INSERT INTO [ApplicationLog] ([AppServerID],[Class],[Level]) (SELECT AppServerID],@[Class],@[Level] FROM AppServerConnection WHERE AppID=@AppID AND ServerID=(SELECT a.ServerID FROM PCServer AS a WHERE a.IntranetIP = @IntranetIP)

慕容森
TA贡献1853条经验 获得超18个赞
Declare @AppServerID nvarchar(50) --- or int
Select @AppServerID=AppServerID FROM AppServerConnection WHERE AppID=@AppID
AND ServerID=(SELECT a.ServerID FROM PCServer AS a WHERE a.IntranetIP = @IntranetIP
Insert into....

翻翻过去那场雪
TA贡献2065条经验 获得超14个赞
前辈你好!你看我这样写对吗!
1 SET ANSI_NULLS ON 2 GO 3 SET QUOTED_IDENTIFIER ON 4 GO 5 6 CREATE PROCEDURE [dbo].[prInsApplicationLog2] 7 @AppID int, 8 @Class nvarchar(512), 9 @Level nvarchar(512), 10 @Thread int, 11 @File nvarchar(512), 12 @Line int, 13 @Message nvarchar(MAX), 14 @TimeGenerated datetime, 15 @CreatedTime datetime, 16 @IntranetIP nvarchar(256) 17 AS 18 BEGIN 19 Declare @AppServerID int 20 Select @AppServerID=AppServerID FROM AppServerConnection WHERE AppID=@AppID 21 AND ServerID=(SELECT a.ServerID FROM PCServer AS a WHERE a.IntranetIP = @IntranetIP) 22 INSERT INTO ApplicationLog 23 (AppServerID,Class,Level,Thread,[File],Line,Message,TimeGenerated,CreatedTime) 24 VALUES 25 (@AppServerID,@Class,@Level,@Thread,@File,@Line,@Message,@TimeGenerated,@CreatedTime) 26 END 27 GO
谢谢谢谢。。。
- 4 回答
- 0 关注
- 695 浏览
添加回答
举报
0/150
提交
取消