SQL Server QA

Source: Internet
Author: User

I. Split line use SQL:
I have a table like this
Id commaseperatedstring
1 A, B, C, D, E
2 x, y, z
What I want is to convert this
Id text
1
1 B
1 c
2 x
2 y
Like this.

Answer:
Select
T. ID, right(left(t.csv, number-1 ),
Charindex(',', reverse(left(','{t.csv, number-1 ))))
From
Master .. spt_values,
Your_table t
Where
Type = 'p' and number between 1 and len(t.csv) + 1
And (substring(t.csv, number, 1) = ',' or substring(t.csv, number, 1) = '')

Source: http://www.sql-server-performance.com/forum/threads/csv-to-columns.32141/#post-166346

 

Ii. Update a table's column inner join another table by a relative Column

Update a set a. Name = csrname from B join (select ID, csrname from B) as B on A. fkid = B. ID

 

Iii. Execute SQL file using command in SQL Server 2008

Osql-s "127.0.0.1"-U "sa"-P "sa"-d "northwind"-I "% Cd % \ 1. SQL"

 

Iv. Using sscm (SQL Server migration Assistant) to migrate data from Oracle to SQL Server

Just click "next" refer to this artice: http://www.cnblogs.com/yinc/archive/2011/07/24/2115345.html, it is useful and convenient.

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.