使用变量确定要从中进行选择的表
这是我得到的新错误:
IF object_id('Osvezi') IS NULL EXEC sp_executesql N' CREATE PROCEDURE Osvezi -- Add the parameters for the stored procedure here @tablica nvarchar(200) AS BEGIN IF @tablica = 'Uporabniki' THEN SELECT * FROM Uporabniki; IF @tablica = 'Dokumenti' THEN SELECT * from Dokumenti; END' GO
this is new error I get:
IF object_id('Osvezi') IS NULL EXEC sp_executesql N' CREATE PROCEDURE Osvezi -- Add the parameters for the stored procedure here @tablica nvarchar(200) AS BEGIN IF @tablica = 'Uporabniki' THEN SELECT * FROM Uporabniki; IF @tablica = 'Dokumenti' THEN SELECT * from Dokumenti; END' GO
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以这样做,但不推荐这样做,
这也取决于您使用的 DBMS; SQL 服务器? MYSQL?后GRESQL?
编辑:
如果您需要这种灵活性,请尝试实体属性值模型
You can do it like this but it is NOT RECOMMENDED
Also it would depend on which DBMS you are using; SQL SERVER? MYSQL? POSTGRESQL?
Edit:
If you need this kind of flexibility, try the Entity-Attribute-Value Model
您需要在字符串中使用两个
''
来获得一个'
,并且需要删除then
。You need to use double
''
in the string to get one'
and you need to removethen
.