This category contains 6 posts

IsNullOrEmpty – A user Defined Function in SQL server

This is an equal implementation of C# function String.IsNullOrEmpty in SQL. This function returns 1 if parameter is NULL or empty. Here is the implementation of this function: Implementation: CREATE FUNCTION dbo.IsNULLOrEmpty(@data varchar(max)) RETURNS BIT AS BEGIN if(NULLIF(@data,”)) is NULL return 1 — return 1 when there is a NULL or Empty. return 0 — … Continue reading

Find stored procedure in all databases

Are you looking for a way to find procedure in all databases? In this post you will find a way to search procedure in all databases. There are some other ways to do so but here it will be demonstrated by using dynamic SQL. The attached procedure will prepare a query with respect to all … Continue reading

For XML Path in .Net – Ups and Downs

INTRODUCTION: We often write ‘FOR XML PATH’ queries in SQL to get data in XML form. Also we can extract unlimited data from a table via XML queries. The problem I am going to discuss today is how to read FULL contents of “FOR XML Path” sql query. I will describe various techniques to retrieve … Continue reading

Retrieve more than 65535 characters from SQL varchar/nvarchar column

Few days ago, I was stuck in a problem to retrieving data from “varchar(max)” column. The data in the column was more than 30k characters. I realized that we can not retrieve more than 65535 characters from the column using this “regular” statement: Select * from TableA   See how it works in sql: In order … Continue reading

Copy one database table rows to another database table

It is a common practice in IT industry that organizations manages data in different databases for different departments. For example a company has a Quality assurance database and a developer database. But they faces an issue when they need a record from some database to their database. In that case, IT person needs to write … Continue reading

SQL Challenge 1

Problem: how do I write a query in SQL to do this? I have a table: name mark u 23 h 38 j 20 p 83 and for output we need name mark mark2 u 23 38 h 38 20 j 20 83 p 83 0 Solution: The query to accomplish the task: is ;WITH … Continue reading