sql server QA

來源:互聯網
上載者:User

一、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 into
ID Text
1 a
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

 

二、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

 

三、 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"

 

四、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.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.