21 articles SQL Server 2008

Useful Microsoft SQL Server Function And Stored Procedure

Dikarenakan masih banyak client yang menggunakan Microsoft SQL Server 2012, maka pada artikel dibuatkan Function dan Stored Procedure yang kompatibel dengan kebutuhan tersebut. Artikel ini akan diupdate secara berkala, silahkan like, comment dan bookmark artikel ini. Version version-1 (2021-01-28) Function Scalar-valued Functions 1. String_Trim Table-valued Functions 1. String_Split Stored Procedure 1. sp_reset_identity

SQL Server Convert Row to Column using Pivot

Mengubah baris menjadi kolom pada SQL Server menggunakan pivot [code lang=”sql”] select order_media_mlr_id, DESIGN, LOCATION from ( select order_media_mlr_id, category, modified_time from order_media_mlr_logs where status = ‘READY_TO_SHOW’ ) d pivot ( max(modified_time) for category in (DESIGN, LOCATION) ) piv; [/code] https://stackoverflow.com/questions/15931607/convert-rows-to-columns-using-pivot-in-sql-server

Fresh Install SQL Server 2014 Cannot Login

Saya baru install SQL Server 2014 dan tidak bisa login. Waktu dicek di “Event Viewer”, ternyata ada file yang gagal diakses oleh SQL Server. Cara memperbaiki file path bisa cek di situs ini https://social.technet.microsoft.com/wiki/contents/articles/31786.sql-server-not-starting-after-fresh-installation.aspx Bagian fix the broken path Reset password user sa, mengikuti cara pada web di atas juga Jika setelah diperbaiki, masih gagal…

SQL Server Select Last Record in One-to-many Relationship

Contoh tabel: customer: id, name purchase: id, customer_id, item_id, date Kita mau mengambil data customer dengan purchase terakhir [code language=”sql”] SELECT c.*, p1.* FROM customer c JOIN purchase p1 ON (c.id = p1.customer_id) LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND (p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id)) WHERE…

Installing the Microsoft.ACE.OLEDB.12.0 Provider for Both 64-bit and 32-bit Processing

Waktu meng-import excel pada Sql Server Management Studio, muncul error The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine. Solusinya meng-install Microsoft.ACE.OLEDB.12.0 Download: https://www.microsoft.com/en-us/download/confirmation.aspx?id=23734 Untuk meng-install di Windows Server 64 bit, perlu menggunakan command prompt Panggil installer dengan parameter /passive, seperti gambar di bawah ini: https://datasavvy.me/2017/07/20/installing-the-microsoft-ace-oledb-12-0-provider-for-both-64-bit-and-32-bit-processing/

SQL Server Concat String

Contoh query di SQL server untuk concat string di tabel one-to-many [code language=”sql”] select b.program_name, b.status, STUFF(( SELECT ‘ ‘ + department FROM order_assigned_departement WHERE (order_assigned_departement.order_id = b.id) FOR XML PATH (”)) , 1, 1, ”) AS department, b.submitted_date, group_id from [order] b where year(submitted_date) = 2017 and month(submitted_date) = 10 and b.cancellation_status is null…