블로그 이미지
LifeisSimple

calendar

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

Notice

2013. 1. 14. 14:23 BookStory

SQL Server Tacklebox

By Rodney Landrum,

DBA Handbooks

SQL Server TackleboxSQL Server Tacklebox - Essential Tools and Scripts for the day-to-day DBA by Rodney Landrum


Download eBook (PDF): Free
Printed Book: $29.99
Download the ePub version: Free

For the day-to-day DBA, there are dangers around every corner; monsters waiting to strike down the unsuspecting database with a resource-hungry query, an inefficient data load, or even outright data corruption. When the worst happens, and SQL Server is down, or performance is suffering, customers are quick to complain.. During such difficult periods, you, the DBA, are the centre of attention. Suddenly, three or four people crowd your desk, laser beam focused on your every action, fully expecting you to solve the problem quickly.

The success of your career as a DBA depends largely on how well-prepared you are to deal with such situations. Without verified backups, sound server documentation, and a ready supply of tried-and tested troubleshooting tools, there is no safe place to hide when the monster rears up. All you can do is buy some time, patch things up as best you can and then duck away into your cubicle, which, if you lost any data in the process, may soon be empty.

However, with the tools and techniques provided in the SQL Server Tacklebox, you will be fully-equipped to fight back. Inside, you'll find scripts that will allow you to automate and standardize SQL Server installation, document and report on your servers, migrate data and manage data growth, troubleshoot performance issues, receive notifications of impending danger, secure access to your servers and fight off data corruption.

In short, you'll be able to respond quickly and professionally to the many issues that blight the waking, and often sleeping, hours of the DBA. Then, one day, who knows? That cubicle may turn into an executive office with wall-to-wall tinted windows revealing a flowing brook outside, where no monsters live.

View Related Books:


Editorial Review

For the day-to-day DBA, there are dangers around every corner; monsters waiting to strike down the unsuspecting database with a resource-hungry query, an inefficient data load, or even outright data corruption. When the worst happens, and SQL Server is down, or performance is suffering, customers are quick to complain.. During such difficult periods, you, the DBA, are the centre of attention. Suddenly, three or four people crowd your desk, laser beam focused on your every action, fully expecting you to solve the problem quickly.

The success of your career as a DBA depends largely on how well-prepared you are to deal with such situations. Without verified backups, sound server documentation, and a ready supply of tried-and tested troubleshooting tools, there is no safe place to hide when the monster rears up. All you can do is buy some time, patch things up as best you can and then duck away into your cubicle, which, if you lost any data in the process, may soon be empty.

However, with the tools and techniques provided in the SQL Server Tacklebox, you will be fully-equipped to fight back. Inside, you'll find scripts that will allow you to automate and standardize SQL Server installation, document and report on your servers, migrate data and manage data growth, troubleshoot performance issues, receive notifications of impending danger, secure access to your servers and fight off data corruption.

In short, you'll be able to respond quickly and professionally to the many issues that blight the waking, and often sleeping, hours of the DBA. Then, one day, who knows? That cubicle may turn into an executive office with wall-to-wall tinted windows revealing a flowing brook outside, where no monsters live.

About the Author

Rodney Landrum has been working with SQL Server technologies for longer than he can remember (he turned 40 in May of 2009 so his memory is going). He writes regularly about many SQL Server technologies, including Integration Services, Analysis Services, and Reporting Services. He has authored three books on Reporting Services. He is a regular contributor to SQL Server Magazine and Simple-Talk, the latter of which he sporadically blogs on about SQL and his plethora of geek tattoos. His day job finds him overseeing the health and well-being of a large SQL Server infrastructure in Pensacola, Florida. He swears he owns the expression "Working with Databases on a Day to Day Basis" and anyone who disagrees is itching to arm wrestle. Rodney is also a SQL Server MVP.

'BookStory' 카테고리의 다른 글

[독서] 완벽의 추구  (0) 2016.11.04
[독서] 혁신의 설계자  (0) 2016.11.04
사고싶은 책들~~~  (0) 2012.05.25
[도서] iSad ...  (0) 2011.10.07
[도서] 관심을 가지고 있는 도서  (0) 2011.09.20
posted by LifeisSimple
2013. 1. 14. 13:21 Photograph by ../일상

아이폰의 고질적인 문제인 홈버튼... 


딱밤도 해보고 별짓을 다 해보는데.. 결국은 큰 효과는 없네요.. 


이럴때 요런 방법을 사용하면... 나름의 효과를 거둘수 있다고 합니다. 



http://tvcast.naver.com/v/23086



위의 동영상을 참고~

posted by LifeisSimple
2013. 1. 14. 11:26 Brain Trainning/DataBase

MSSQL 과 MySQL 의 함수 비교자료 입니다. 

MSSQL 을 사용하다 MySQL 도입을 검토하거나 그 반대의 경우 나름의 유용한 자료가 될 듯 합니다.


January 7, 2013

Comparing SQL Server and MySQL Functions

By Rob Gravelle

This article is the second part in a series examining some of the challenges in porting your databases between MS SQL Server and MySQL.  In Part 1, we looked at some of the differences between data types utilized by each DBMS.  Today, in moving on to functions, you’ll see how functions may require additional effort on your part to produce equivalent results.

Function Categories

Functions can be divided into three distinct categories:

  1. Equivalent Functions: Those that can be safely migrated from one database type to another without any modifications whatsoever.
  2. Emulated Functions: Functions that are available in one database, but not the other.  Another problematic issue is that some MySQL functions have a variable parameter count.  In either case, some conversion work is required. 
  3. Non-supported Functions: Those which cannot be easily ported because of logical/physical organization and security model differences.

Equivalent Functions

You’ll be happy to know that the following functions are usable in both MySQL and SQL Server queries without any modifications:

ASCII, LEFT, LOWER, LTRIM, REPLACE, REVERSE, RIGHT, RTRIM, SOUNDEX, SPACE, SUBSTRING, UPPER, ABS, ACOS, ASIN, ATAN, ATAN2, CEILING, COS, COT, DEGREES, EXP, FLOOR, LOG, LOG10, PI, POWER, RADIANS, RAND, ROUND, SIGN, SIN, SQRT, TAN, DAY, MONTH, COALESCE, NULLIF, CAST, CONVERT.

Emulated Functions

Functions that have no equivalent on the other platform are where the bulk of your efforts will go, as converting these can be like trying to fit a round peg into a square hole.

The Transact-SQL
CASE function

CASE WHEN @a > @b 
     THEN @a 
     ELSE @b - @a 
END 

This can be converted to the MySQL  IF(expr1, expr2, expr3)  function.  Here’s how it works:

If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL), IF() returns expr2; otherwise it returns expr3.

MySQL example:

if(@a>@b, @a, @b-@a) 
Converting Binary Data into a Varchar

IN SQL SERVER 2008 the convert function was extended to support binary data to hex string conversion. Hence, you might see something like this:

CONVERT(NVARCHAR(34), 0xc23eed6b65c93e44a41a2818e274194f, 1) AS BINARY_TO_STRING

The MySQL BIN(N)  function, which returns a string representation of the binary value of N, can be utilized in its stead.

The Transact-SQL  DATALENGTH Function

This one is easy to convert because both the SQL Server DATALENGTH and MySQL BIT_LENGTH functions will return the length of a string in bits.

String Concatenation

SQL Server does not support the ANSI SQL CONCAT() function.  Instead, it uses the plus operator (+) for string concatenation:

'A'+'B'+'C', 'A'+'#'+'B'+'#'+'C' 

In MySQL, use the CONCAT(str1, str2, ….) or CONCAT_WS(separator, str1, str2, ...)  functions, which return the concatenated arguments:

CONCAT('A','B','C'), CONCAT_WS('#','A','B','C') 
Converting Numbers between Different Number Bases

It is sometimes useful to convert a number to a non-base 10 string. In SQL Server, that requires using the CAST function or employing a user-defined function.  In MySQL, you can forget about all that, as the ANSI SQL CONV(N, from_base, to_base)  function will allow you to convert from one base to another with ease.

Finding the Position of the First Occurrence of a Substring within a String

The Transact-SQL CHARINDEX function maps exactly to the ANSI  SQL LOCATE() function.

Inserting a String within Another

In SQL Server, the REPLACE function can be used to replace part of a string with another. For instance, the following example replaces the string def in abcdefghi with xyz.

SELECT REPLACE('abcdefghicde','def','xyz');

MySQL’s INSERT(str, pos, len, newstr) function is a reasonable facsimile, as it returns the string str, with the substring that begins at position pos and is len characters long replaced by the string newstr.

Loading Data and Statements from a File

T-SQL bulk load statements and extended stored procedures that load data and executable statements from a text file can be replace with LOAD_FILE(file_name)  in MySQL.

Getting the Current Date

Transact-SQL’s  NOW function maps to GETDATE in ANSI SQL.

Generating a Repeating String

Transact-SQL’s  REPLICATE function maps exactly to REPEAT in ANSI SQL.

Testing for NULL

Transact-SQL relies on the CASE and IS NULL clauses to check for NULL values. In MySQL, you can simply use the ISNULL(expr) function instead.  If expr is NULL, ISNULL() returns 1; otherwise it returns 0.

Comparing Two Strings

Transact-SQL relies on comparison operators to compare strings, whereas ANSI SQL provides the STRCMP(expr1, expr2)  function.

Formatting Dates

While Transact-SQL uses a combination of date, string, and convert functions to format dates as strings, ANSI SQL has the built-in DATE_FORMAT(date, format) function specifically for formatting dates.

Adding an Interval to a Given Date

The Transact-SQL DATEADD function does have equivalents in Oracle, DB2, and PostgreSQL. MySQL includes the same function, except that it’s called DATE_ADD:

SELECT DATE_ADD('2010-12-31 23:59:59', INTERVAL 1 DAY);

returns '2011-01-01 23:59:59'
Converting between Seconds and a Time

In Transact-SQL, converting between seconds and a time such as 12:34:00 can be accomplished using a combination of the CONVERT and DATEADD functions.  For instance, here is a statement that converts seconds to a time:

CONVERT(char(8), DATEADD(second, Diff, '0:00:00'), 108)

MySQL can convert between seconds and a time more easily using the SEC_TO_TIME(seconds)  and TIME_TO_SEC(time) functions.

Retrieving the Last Inserted ID

The Transact-SQL @@IDENTITY and SCOPE_IDENTITY functions are used to retrieve the last inserted ID.  MySQL possesses a similar function called LAST_INSERT_ID for this purpose.

Concatenating Column Values

To concatenate the contents of a column into a string requires a few steps in T-SQL:

declare @v varchar(max) 
set @v='' 

select @v=@v+','+isnull(field_a,'') from table_1 
select substring(@v,2,len(@v)) 

It’s much easier in ANSI SQL, thanks to the GROUP_CONCAT function.  It comes in two flavors to support 
different formats:

  • GROUP_CONCAT( Language SEPARATOR ‘-’ ) will use the dash instead of  the default comma separator.
  • SELECT GROUP_CONCAT( Language ORDER BY Language DESC ) can be used to change the sorting order.

Note that GROUP_CONCAT ignores NULL values.

Non-supported Functions

Any SQL Server-centric functions have to be either removed and/or rewritten using a combination of ANSI SQL statements.  Once completed, the new code can be saved as a user-defined function for easy reuse.

Conversion Tools

There are purportedly some automated tools that can convert stored procedures between SQL Server and MySQL, such as SQLWays by Ispirer.   According to their site and anecdotal reports, it converts stored procedures, functions, packages and triggers.  All this automation doesn’t come cheap; at about a grand USD, it may be more cost effective to manually convert your procs.


출처 : http://www.databasejournal.com/features/mysql/comparing-sql-server-and-mysql-functions.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+DatabaseJournalNews+%28Database+Journal+News%29&utm_content=Google+Feedfetcher

posted by LifeisSimple
prev 1 next