Different methods to extract decimal part from a number
One of the questions asked in a forum. "What are the different methods to extract decimal part from a number?".There can be several methods. These are the ones I know. Method 1 : Substract the INTeger...
View ArticleUnderstanding how ISNUMERIC function works
Often I hear from people that ISNUMERIC function is not working properly and there is a bug. One example people refer is that both of ISNUMERIC('12d2') and ISNUMERIC (',') return the value 1. Well. The...
View ArticleSQL Server does not allow to create a TEMP table twice in the same batch,...
In SQL Server, a temporary table with the same name could not be re-created in the same batch, even if you drop and re-create. The following script clarifies the concept. Try by self CREATE PROCEDURE...
View ArticleDROP command with multiple tables
There is a question in the forum where questioner asked "I created lot of temporary tables like #temp1, #temp2, #temp3, etc. Is there a way to drop them all in a single statement?" Well. Not many...
View ArticleMoney datatype and formatted values
Money is one of the datatypes in SQL Server and it can be used to store monetary values. It will not only accept integer and decimal values but formatted values too. For example you can express values...
View ArticleWhen exactly scheduled jobs started and completed - SQL Server
Some days ago, i worked to get failed jobs detail and an alert for the same. I used some system tables from msdb database to fetch the details for same. And msdb.dbo.sysjobhistory is one of the table...
View ArticleThe EXECUTE permission was denied on the object 'xp_sqlagent_enum_jobs' - SQL...
Recently while working with one query to get schedule jobs status, i used xp_sqlagent_enum_jobs object which gives details of state values of all jobs in msdb database and this is undocumented object....
View ArticleMoving table or indexes on another filegroup - SQL Server
Because of data growth and performance issue we need to move tables or indexes to other filegroups. The purpose of moving tables or indexes to improve the database performance as it reduce I/O from...
View ArticleConditional aggregation - SUM Vs COUNT
You can do conditional aggregation like SUM(CASE WHEN .. THEN 1 ELSE 0 END),....etc to find a count for a particular match. This type of conditions are useful when you want to write a CROSS-TAB/PIVOT...
View ArticleFailed to acquire connection. Connection may not be configured correctly -...
This week, I resolved one issue which I received continuously which is noting but exactly displayed in post title. The issue occurred when I ran ssis package with batch file or scheduled job and same...
View ArticleHandling multiple resultsets returned from Stored Procedure
One of my friends asked me if it is possible to load multiple resultsets returned from a stored procedure into a temporary table for some analysis purpose. The answer is "It depends". If all the...
View ArticleAdding/Modifying files and filegroup in Database - SQL Server
You all know about the database file structure as whenever we created databases without specifying file location and filegroups , they will be created in default path and default filegroup. Here i have...
View ArticleBCP - Changing the default column terminator
BCP is one of the fastest methods to export data to various formats like csv,txt,etc and doing this in a command mode is faster than doing it via SSMS.Let us create this simple tablecreate table...
View ArticleHow to increase the number of characters retrieved from the server for XML...
You may worked with xml and you may aware of title mentioned in this post. Today when I was working to collect information from one table which having xml column, I was trying to open xml data result...
View ArticleGO statment
Today i studied an interesting thing related to GO statment See in the following queries executed .***The batch preceding GO will execute the specified number of times***. create table test( id int not...
View ArticleImport data - solving data convertion and truncation error
Often developers use Import wizard from SSMS or SSIS to import data from a text file into a table. You may or may not import it successfully based on the nature of the data.Create a text file named...
View ArticleSkip distributor agent error in sql server transactional replication - How to
A while before few weeks, I discussed about an error of replication “The row was not found at the Subscriber when applying the replicated command”. We had a tricks to get discrepancies for error table...
View ArticlePrint screen for Remote Desktop
Earlier on Beyondrelational I read a tip, for the same topic. combination of keys Shift + Print screen, allows us to take screen shot of Remote Desktop. But recently I faced problem using these keys....
View ArticleMerge statement with TOP clause - SQL Server
A week ago, I posted for Insert, Update and Delete statement with TOP clause and Merge statement as individual post. If you not read those posts then read it before to move next. In this posts I used...
View ArticleQuestion of the month February 2013 - How does HAVING clause work without...
When you run the following codeselect name from sys.objects having 1=1you get the following error Msg 8120, Level 16, State 1, Line 2 Column 'sys.objects.name' is invalid in the select list because it...
View Article