如何使用存储过程 [英] how to use store procedure

查看:83
本文介绍了如何使用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的站点中使用存储过程,但是以下SQL未能使用错误的''(.附近的错误语法来创建该过程.
代码如下:

I want to use a stored procedure in my site, but the following SQL failes to create the procedure with an "incorrect syntax near ''(.''" error.
Here''s the code:

CREATE PROCEDURE dbo.StoredProcedure1
AS
	
	
	with [tab]([id],[message],[r_type])
	(
	   SELECT Id, Message,'f'as r_type FROM Friends
	   
	   union all
	   
	   SELECT Id, Message,'s'as r_type FROM Scrap
	
	)
	
	select * from [tab]
	
	RETURN

推荐答案

不需要在其中插入AS吗?
Don''t you need an AS in there?
WITH [tab]([id],[message],[r_type]) AS


这篇关于如何使用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆