嵌套创建存储过程,以及单引号的使用问题

Create procedure dbo.Second
AS
Begin
declare @t as int
print 'hello'
End

Create procedure dbo.First
As
Begin

declare @sql as nvarchar(100)
set @sql = 'Create procedure dbo.test
AS
Begin
declare @t as int
print ''hello''
End'
exec(@sql)

End

当单引号是语句的组成部分时:
如果使用动态sql, 那么其中的单引号(') 要用两个单引号代替('').   如果是在C#中使用动态sql, 那么其中的单引号应该用四个单引号('''')代替.

posted @ 2008-06-12 15:47  Simon.guo  阅读(513)  评论(0编辑  收藏  举报