SQL Tips and Tricks for Day to Day Operations

Replace a string in a SQL Server Table Column

UPDATE MY_TABLE

SET PATH = REPLACE(PATH, ‘OLDSTRING’, ‘NEWSTRING’)

Renaming database table column to new name

SP_RENAME ‘TABLENAME.[OLDCOLUMNNAME]’ , ‘[NEWCOLUMNNAME]’, ‘COLUMN’

Renaming database table or SP to new name

SP_RENAME ‘[OLDTABLENAME]’ , ‘[NEWTABLENAME]’

Add one column into existing SQL Table

ALTER TABLE TABLENAME ADD COLUMN_NAME  DATATYPE

Happy Querying 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s