今天发现个奇怪的问题,先贴代码:
- SQL code
SET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GOALTER FUNCTION dbo.fn_server81v12test_get_layouts_for_widget( @widget_id int)RETURNS VARCHAR(500)ASBEGIN DECLARE @str varchar(500) SET @str = '' SELECT @str = @str + CAST(layout_no AS varchar(3)) + ', ' FROM [server81v12test_layout_placeholder] WHERE widget_id = @widget_id IF LEN(@str) > 0 SET @str = SUBSTRING(@str, 1, LEN(@str)-1) RETURN @strENDGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO
这函数里面有个表[server81v12test_layout_placeholder],在运行这个函数的时候:
Server: Msg 208, Level 16, State 1, Procedure fn_server81v12test_get_layouts_for_widget, Line 19
Invalid object name 'server81v12test_layout_placeholder'.
但是这个表确实是存在的,我单独拿出里面的code跑的时候能出来结果,我就很费解,这是为什么?
我的是sql 2000,元芳,此事你如何看?
------解决方案--------------------
因为你现在用的账号所属架构不是dbo,SQLServer从05以后,架构的重要性越来越高