开发者

SQL Server 2008 dynamic query doubt [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

What is the purpose of system table table master..spt_values and what are the meanings of its values?

Why (and how) to split column using master..spt_values?

I have some dynamic SQL, I have this lines tha开发者_运维技巧t will be executed, whats the meaning of spt_values, and the type='P'

declare @Sql nvarchar(max)
select @Sql = ISNULL(@sql + ',', '') + QUOTENAME(RIGHT(number,10))
    from master..spt_values 
    where type='P' and number between 1 and (select COUNT(*) From tableName)


spt_values is a table in the master database. As such, it's meant for internal SQL Server use only, and is undocumented to the public.

Basically the code you've got is a quick way to get your hands on a resultset of numbers.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜