开发者

Concatenating literals with expressions using t-sql 2005 and above

开发者 https://www.devze.com 2023-03-21 12:12 出处:网络
I hope someone can shed some light on this.I can\'t believe I never noticed this issue before.It\'s really irritating me.

I hope someone can shed some light on this. I can't believe I never noticed this issue before. It's really irritating me.

Why is it not possible to do inline concatenation using stored procs (I haven't tried with function开发者_如何学运维s yet)?

Look at this example I created. This will not complete with execution. It will fail on line 5.

It seems like overkill to make the developer have to create a variable possibly and issue a set command anywhere that it is required to insert some concatenated value into a sp.

Please tell me I'm over looking something.

DECLARE @WORLD NVARCHAR(MAX)
SET @WORLD = 'WORLD'
PRINT  'HELLO ' + @WORLD

exec sp_profileColumn 'dbo' + '.' + @WORLD --THIS STATEMENT FAILS

set @WORLD = 'dbo' + '.' + @WORLD

exec sp_profileColumn @WORLD  --LOGICALLY THIS STATEMENT IS THE SAME AS LINE 5, CORRECT?


I agree that it is unfortunate, but it has been that way for a long time in SQL Server.

0

精彩评论

暂无评论...
验证码 换一张
取 消