SQL Server in master: Application of Spt_values

Source: Internet
Author: User
Select number from Master. Spt_values with (nolock) where type= ' P '/** explained: Master. The corresponding Number field value for the Spt_values table's field value is p from 0-2047*/--1. Converting a string to a column shows if OBJECT_ID (' TB ') is not null drop table TB go CREATE TABLE TB ([numbered ] varchar (3), [Product] varchar (2), [quantity] int,[unit Price] int,[amount] int,[serial number] varchar (8)) insert into TB ([number],[product],[quantity],[Unit price],[amount],[Serial number] Select ' 001 ', ' AA ', 3,5,15, ' 12,13,14 ' Union allselect ' 002 ', ' BB ', 8,9,13, ' 22,23,24 ' Go SELECT [number],[product],[quantity],[Unit price],[amount], SUBSTRING ([Serial number],b.number,charindex (', ', [serial number]+ ', ', B.number)-b.number) as [serial number] from TB A with (NOLOCK), Master: Spt_values B with (NOLOCK) where b.number>=1 and B.number

SQL Server in master: Application of Spt_values

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.