You are here:
Home >Archive for the ‘
Database Tutorials’ Category
Posted in
MS SQL | March 22nd, 2012
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: Rename a Column, SQL, SQL Authority, SQL Query, SQL Scripts, SQL SERVER, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology
Posted in
MySQL | February 23rd, 2012
Table of contents : What is MySQL grant? How to GRANT privileges to users Resources What is MySQL grant The MySQL database software offers both administrators and users a great amount of control options. You can learn more about the users’ MySQL management rights in our articles dedicated to the create-user, create-database, create-table and alter-table [...]
Tags: MySQL grant, user permissions, สิทธิ์ mysql
Definition and Usage The DATEDIFF() function returns the time between two dates. Syntax DATEDIFF(datepart,startdate,enddate) Where startdate and enddate are valid date expressions and datepart can be one of the following: datepart Abbreviation year yy, yyyy quarter qq, q month mm, m dayofyear dy, y day dd, d week wk, ww weekday dw, w hour hh [...]
Tags: DATEDIFF, SQL DATEDIFF, SQL Server DATEDIFF
The ALTER TABLE statement allows you to rename an existing table. It can also be used to add, modify, or drop a column from an existing table. Renaming a table The basic syntax for renaming a table is: ALTER TABLE table_name RENAME TO new_table_name; For example: ALTER TABLE suppliers RENAME TO vendors; This will [...]
Tags: add a column, add multiple columns, ALTER TABLE, DROP COLUMN, modify column, modify multiple columns, sql rename table
Posted in
MS SQL | February 10th, 2012
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: sp_RENAME, SQL, SQL Authority, SQL Query, SQL Scripts, SQL SERVER, SQL SERVER Name Table, SQL SERVER Rename Column, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology
Posted in
MS SQL | February 9th, 2012
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: bulk insert csv error, Msg 4861, Pinal Dave, SQL, SQL Authority, SQL Query, SQL Scripts, SQL SERVER, SQL Tips and Tricks, SQL Utility, T SQL, Technology
Posted in
MS SQL | February 8th, 2012
Introduction One of the fairly frequently asked questions on the Microsoft replication discussion boards concerns how to alter a replicated article. For simple cases this is quite straightforward – adding a column is achieved using sp_repladdcolumn, while sp_repldropcolumn is used to drop a column. However, what if we want to change an existing column – [...]
Tags: add a column on a Replicated Table, alter a column on a Replicated Table, Alter a Replicated Article
Posted in
MS SQL | February 8th, 2012
Sometimes the schema of a replicated table needs altering. There are many reasons this might be the case eg possibly the datatype has been incorrectly chosen, or a default is missing, or we want to rename a column. Attempting to change the table schema directly will result in the error “Cannot alter/drop the table ‘tablename’ [...]
Tags: Alter Replicated Table
Posted in
MS SQL | February 8th, 2012
A dump device is simply a logical device which redirects to a specified physical device. The main advantage of using a dump device for backups is it reduces the change required to backup code. For example, if you are backing up to a Network location. If you have hard-coded the backup location then the network [...]
Tags: Backup & Recovery, Catalog Views, Management Studio, SQLServer
Posted in
MS SQL | February 8th, 2012
Getting row count for all tables in a database is straight forward. You can display row count for all tables by joining sys.objects and sys.partitions as below: USE [AdventureWorks2008R2] GO SELECT SCHEMA_NAME(A.schema_id) + ‘.’ + A.Name, SUM(B.rows) AS ‘RowCount’ FROM sys.objects A INNER JOIN sys.partitions B ON A.object_id = B.object_id WHERE A.type [...]
Tags: Row count for all tables, Row count for all views, SQL Server count all