等了好久,總算等到台灣開賣了,當然要趁聖誕節買一個來玩玩看囉!!
戴在手上其實很輕,沒有什麼感覺,可能要小心的就是不小心擠壓到彈飛出去吧XD
DECLARE @spid int, @SQLstr nvarchar(128) DECLARE spids_cr CURSOR FOR SELECT p.spid FROM sys.sysprocesses P JOIN sys.sysdatabases D ON (D.dbid = P.dbid) JOIN sys.sysusers U ON (P.uid = U.uid) WHERE hostname != '' AND hostname = @hostname AND [P].[program_name]='.Net SqlClient Data Provider ' FOR READ ONLY OPEN spids_cr FETCH spids_cr INTO @spid WHILE (@@FETCH_STATUS=0) BEGIN SET @SQLstr = 'KILL ' + CAST(@spid AS varchar) EXEC sp_executesql @SQLstr FETCH spids_cr INTO @spid END CLOSE spids_cr DEALLOCATE spids_cr參考:http://www.stev.org/post/2011/03/01/MS-SQL-Kill-connections-by-host.aspx http://sharedderrick.blogspot.tw/2008/01/kill-all-connection.html
SELECT object_name, counter_name, cntr_value AS 'Total Server Memory (KB)'
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Total Server Memory (KB)'
不過看起來好像有點不準,於是繼續尋找其他方法,SELECT SUSER_SID('UserName') as SID, LOGINPROPERTY('UserName','PasswordHash') as Password這樣可以查出 UserName 的 SID 跟 Password 之後,再去第二台建立帳號
CREATE LOGIN [UserName] WITH PASSWORD = 0x02004E8321B1C292991E5B4CF64E3983B3736C59567C2736910F3E0B17BCEF6DFE0BB37AE03A6FAA9CEB3AC2BB1DE290C08710B25C0DD78D708532D54B2888A590BB2BE4200E HASHED, SID = 0x849A0DE6AEF87147BF0588C621CE91AF, DEFAULT_DATABASE = [master], CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF
Sub simpleXlsMerger() Dim bookList As Workbook Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object Application.ScreenUpdating = False Set mergeObj = CreateObject("Scripting.FileSystemObject") 'change folder path of excel files here Set dirObj = mergeObj.Getfolder("D:\Excels\") Set filesObj = dirObj.Files For Each everyObj In filesObj Set bookList = Workbooks.Open(everyObj, UpdateLinks:=False, ReadOnly:=True) ActiveSheet.AutoFilterMode = False bookList.Worksheets("Sheet1").Select bookList.Worksheets("Sheet1").AutoFilterMode = False 'change "A2" with cell reference of start point for every files here 'for example "B3:IV" to merge all files start from columns B and rows 3 'If you're files using more than IV column, change it to the latest column 'Also change "A" column on "A65536" to the same column as start point Range("A2:IV" & Range("A65536").End(xlUp).Row).Copy ThisWorkbook.Worksheets(1).Activate 'Do not change the following column. It's not the same column as above Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial Application.CutCopyMode = False bookList.Close False Next End Sub
Sub simpleXlsMerger() Dim bookList As Workbook Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object Application.ScreenUpdating = False Set mergeObj = CreateObject("Scripting.FileSystemObject") '修改Excel檔的所在資料夾 Set dirObj = mergeObj.Getfolder("D:\Excels\") Set filesObj = dirObj.Files For Each everyObj In filesObj Set bookList = Workbooks.Open(everyObj, UpdateLinks:=False, ReadOnly:=True) ActiveSheet.AutoFilterMode = False bookList.Worksheets("Sheet2").Select bookList.Worksheets("Sheet2").AutoFilterMode = False '我只要這個範圍的資料 Range("A4:L4").Copy ThisWorkbook.Worksheets(1).Activate 'Do not change the following column. It's not the same column as above Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues Application.CutCopyMode = False bookList.Close False Next End Sub
protected void btnL2R_Click(object sender, EventArgs e) { //先把選中的都放到右邊去 foreach (int i in LeftListBox.GetSelectedIndices()) { LeftListBox.Items[i].Selected = false; RightListBox.Items.Add(LeftListBox.Items[i]); } //在從右邊將左邊的刪除 foreach (ListItem li in RightListBox.Items) { LeftListBox.Items.Remove(li); } } protected void btnR2L_Click(object sender, EventArgs e) { //先把選中的都放到左邊去 foreach (int i in RightListBox.GetSelectedIndices()) { RightListBox.Items[i].Selected = false; LeftListBox.Items.Add(RightListBox.Items[i]); } //在從左邊將右邊的刪除 foreach (ListItem li in LeftListBox.Items) { RightListBox.Items.Remove(li); } }
SELECT a.[FormID] ,left(a.[Authority],LEN(a.[Authority])-1) AS [Description] FROM (SELECT [FormID],(SELECT CAST([AuthType] AS NVARCHAR ) + ',' FROM [FormAuth] WHERE [FormId] = o.[FormId] FOR XML PATH('')) AS [Authority] FROM [FormAuth] o GROUP BY [FormID]) a ORDER BY [FormID]
<!-- varchar --> <dtm:DataTypeMapping > <dtm:SourceDataType> <dtm:DataTypeName>varchar</dtm:DataTypeName> </dtm:SourceDataType> <dtm:DestinationDataType> <dtm:CharacterStringType> <dtm:DataTypeName>DT_STR</dtm:DataTypeName> <dtm:UseSourceLength/> </dtm:CharacterStringType> </dtm:DestinationDataType> </dtm:DataTypeMapping> <dtm:DataTypeMapping > <dtm:SourceDataType> <dtm:DataTypeName>200</dtm:DataTypeName> </dtm:SourceDataType> <dtm:DestinationDataType> <dtm:CharacterStringType> <dtm:DataTypeName>DT_STR</dtm:DataTypeName> <dtm:UseSourceLength/> </dtm:CharacterStringType> </dtm:DestinationDataType> </dtm:DataTypeMapping>
<!-- nvarchar --> <dtm:DataTypeMapping > <dtm:SourceDataType> <dtm:DataTypeName>nvarchar</dtm:DataTypeName> </dtm:SourceDataType> <dtm:DestinationDataType> <dtm:CharacterStringType> <dtm:DataTypeName>DT_WSTR</dtm:DataTypeName> <dtm:UseSourceLength/> </dtm:CharacterStringType> </dtm:DestinationDataType> </dtm:DataTypeMapping> <dtm:DataTypeMapping > <dtm:SourceDataType> <dtm:DataTypeName>202</dtm:DataTypeName> </dtm:SourceDataType> <dtm:DestinationDataType> <dtm:CharacterStringType> <dtm:DataTypeName>DT_WSTR</dtm:DataTypeName> <dtm:UseSourceLength/> </dtm:CharacterStringType> </dtm:DestinationDataType> </dtm:DataTypeMapping>