You are here: Home >Posts Tagged ‘SQL

SQL SERVER – How to Rename a Column Name or Table Name

I often get request from blog reader for T-SQL script to rename database table column name or rename table itself. The script for renaming any column : sp_RENAME ‘TableName.[OldColumnName]‘ , ‘[NewColumnName]‘, ‘COLUMN’ The script for renaming any object (table, sp etc) : sp_RENAME ‘[OldTableName]‘ , ‘[NewTableName]‘ This article demonstrates two examples of renaming database object. [...]

Tags: , , , , , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL SERVER – How to Rename a Column Name or Table Name

I often get request from blog reader for T-SQL script to rename database table column name or rename table itself. The script for renaming any column : sp_RENAME ‘TableName.[OldColumnName]‘ , ‘[NewColumnName]‘, ‘COLUMN’ The script for renaming any object (table, sp etc) : sp_RENAME ‘[OldTableName]‘ , ‘[NewTableName]‘ This article demonstrates two examples of renaming database object. [...]

Tags: , , , , , , , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL SERVER – Import CSV File Into SQL Server Using Bulk Insert – Load Comma Delimited File Into SQL Server

bulk insert csv sql server Server: Msg 4861, Level 16, State 1, Line 1 This is very common request recently – How to import CSV file into SQL Server? How to load CSV file into SQL Server Database Table? How to load comma delimited file into SQL Server? Let us see the solution in quick [...]

Tags: , , , , , , , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL SERVER – Attach mdf file without ldf file in Database

Background Story: One of my friends recently called up and asked me if I had spare time to look at his database and give him a performance tuning advice. Because I had some free time to help him out, I said yes. I asked him to send me the details of his database structure and [...]

Tags: , , , , , , , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL DROP INDEX, DROP TABLE, DROP VIEW, DROP DATABASE

บทความความนี้จะมาแนะนำวิธีการลบอินเด็กซ์ เทเบิล วิว และดาต้าเบส ด้วยรูปแบบคำสั่งของ SQL Command ง่ายๆ ครับ. Indexes, tables, view,and databases can easily be deleted/removed with the DROP statement.

Tags: , , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL CREATE INDEX Statement

บทความนี้จะพูดถึงการสร้าง index หรือ CREATE INDEX ก่อนอื่นต้องมาทำความเข้าใจก่อนว่า Index มีหน้าอะไร Index ก็เหมือนสารบัญของหนังสือ ที่ช่วยให้เราอ่านหรือค้นหาเนื้้อหาที่ต้องการด้วยความเร็ว และเร็วกว่าการเปิดอ่านที่ละหน้าเพื่อหาเนื้อหาที่ต้องการ หากเป็นดาต้าเบสก็เหมือนกันเราก็จะต้องไม่ต้อง Scan table ทั้งหมดนั้นเอง The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading the whole table.

Tags: , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL DEFAULT Constraint

SQL DEFAULT Constraint เป็นการกำหนดค่าเริ่มต้นเวลาเพิ่มข้อมูล แล้วไม่ได้มีค่าตัวแปรในคอลัมน์นี้ ก็จะมีการนำเอาค่าเริ่มต้นมาเพิ่มลงในคอลัมน์ The DEFAULT constraint is used to insert a default value into a column. The default value will be added to all new records, if no other value is specified.

Tags: , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL CHECK Constraint

SQL CHECK Constraint ใช้สำหรับกำหนดค่าของข้อมูลก่อนทำการเพิ่มหรือแก้ไข หากไม่ตรงเงื่อนไขก็ไม่สามารถเพิ่มหรือแก้ไขได้ครับ หากกำหนด CHECK constraint on a single column  จะกำหนดเพียงค่าเดียวของคอลัมน์ ก็จะทำการตรวจสอบเฉพาะคอลัมน์ที่กำหนดเท่านั้น หากกำหนด CHECK constraint on a table  จะกำหนดได้หลายค่าของคอลัมน์ในเทเบิล

Tags: , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL FOREIGN KEY Constraint

FOREIGN KEY เป็นค่าในเทเบิลที่เป็นค่าของ PRIMARY KEY อีกเทเบิลหนึ่ง A FOREIGN KEY in one table points to a PRIMARY KEY in another table.

Tags: , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

SQL NOT NULL Constraint

คำสั่ง SQL NOT NULL constraint เป็นคำสั่งที่ใช้สำหรับจำกัดค่าในคอลัมน์นั้นห้ามเป็นค่าว่าง หากมีการเพิ่มข้อมูลแล้วคอลัมน์ดังกล่าวว่างหรือไม่มีข้อมูลก็จะไม่สามารถเพิ่มหรือแก้ไขให้เป็นว่างได้ The NOT NULL constraint enforces a column to NOT accept NULL values. The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or update a record without adding a value to this field. The following SQL enforces [...]

Tags: , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS