简单的方法来执行exec sp

编程入门 行业动态 更新时间:2024-10-24 06:37:20
本文介绍了简单的方法来执行exec sp_executesql到一个正常的查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在处理使用Profiler和SSMS的查询时,对于我来说,从Profiler复制查询并在SSMS中测试它们是很常见的。因为我使用参数化的sql,所以我的查询都以exec sp_executesql查询的形式发送。

exec sp_executesql N'/ *这里有一些查询* /', N'@ someParameter tinyint ', @ someParameter = 2

我会把它转换成正常查询易于编辑(intellisense,错误检查,行号等):

DECLARE @someParameter tinyint SET @someParameter = 2 / *这里有一些查询* /

查询越大越复杂,难度越大。当你多次来回的时候,这可能是一个痛苦的屁股,并吸收了大量的时间。

有没有一个简单的(例如,宏命令)的方式来将muh executionql转换成更方便的东西?

解决方案

我不知道现有的加载项可以做这个。但是你可以创建一个:)

一些正则表达式和一些字符串连接,然后把它卖给Vinko和其他寻找这个功能的灵魂。

如果您想深入了解这一点,下面是创建SSMS插件的一些信息: sqlblogcasts/blogs/jonsayce/archive/2008/01/ 15 / building-a-sql-server-management-studio-addin.aspx

When dealing with debugging queries using Profiler and SSMS, its pretty common for me to copy a query from Profiler and test them in SSMS. Because I use parameterized sql, my queries are all sent as exec sp_executesql queries.

exec sp_executesql N'/*some query here*/', N'@someParameter tinyint', @ someParameter =2

I'll take this and convert it into a normal query for ease of editing (intellisense, error checking, line numbers, etc):

DECLARE @someParameter tinyint SET @someParameter = 2 /*some query here*/

Of course, the bigger and more complex the query, the harder to do this. And when you're going back and forth multiple times, it can be a pain in the ass and soak up lots of time.

Is there an easy (e.g., macro command) way to convert muh executesql into something more convenient?

解决方案

I am not aware of an existing Add-In that can do this. But you could create one :)

A few regular expressions and some string concatenation and after that sell it to Vinko and other souls looking for this functionality.

If you're feeling like diving into this, here is some information on creating an SSMS addin: sqlblogcasts/blogs/jonsayce/archive/2008/01/15/building-a-sql-server-management-studio-addin.aspx

更多推荐

简单的方法来执行exec sp

本文发布于:2023-11-12 23:51:28,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法来   简单   sp   exec

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!