Thursday, 26 April 2018

Search all tables, all columns for a specific value SQL Server

DECLARE @SearchStr nvarchar(100)
SET @SearchStr = 'narendra'

CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET  @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

WHILE @TableName IS NOT NULL

BEGIN
    SET @ColumnName = ''
    SET @TableName =
    (
        SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
        FROM     INFORMATION_SCHEMA.TABLES
        WHERE         TABLE_TYPE = 'BASE TABLE'
            AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
            AND    OBJECTPROPERTY(
                    OBJECT_ID(
                        QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                         ), 'IsMSShipped'
                           ) = 0
    )

    WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
       
    BEGIN
        SET @ColumnName =
        (
            SELECT MIN(QUOTENAME(COLUMN_NAME))
            FROM     INFORMATION_SCHEMA.COLUMNS
            WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2)
                AND    TABLE_NAME    = PARSENAME(@TableName, 1)
                AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar', 'int', 'decimal')
                AND    QUOTENAME(COLUMN_NAME) > @ColumnName
        )

        IF @ColumnName IS NOT NULL
       
        BEGIN
            INSERT INTO #Results
            EXEC
            (
                'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630) FROM ' + @TableName + ' (NOLOCK) ' +
                ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
            )
        END
    END 
END

SELECT ColumnName, ColumnValue FROM #Results

DROP TABLE #Results

Monday, 6 November 2017

SQL Server creating table with clustered index without a primary key

Yes, it is possible to create a clustered index that is not the primary key. Just use a CREATE CLUSTERED INDEX statement.
CREATE TABLE dbo.myTable (
    myTableId int PRIMARY KEY NONCLUSTERED
    myColumn int NOT NULL
)

CREATE CLUSTERED INDEX myIndex ON dbo.myTable(myColumn)

Thursday, 11 May 2017

String Searching : what is your mobile number?

These days Bechan Chacha is depressed because his crush gave him list of mobile number some of them are valid and some of them are invalid. Bechan Chacha has special power that he can pick his crush number only if he has valid set of mobile numbers. Help him to determine the valid numbers.
You are given a string "S" and you have to determine whether it is Valid mobile number or not. Mobile number is valid only if it is of length 10 , consists of numeric values and it shouldn't have prefix zeroes.

Input:
First line of input is T representing total number of test cases.
Next T line each representing "S" as described in in problem statement.

Output:
Print "YES" if it is valid mobile number else print "NO".
Note: Quotes are for clarity.
Constraints:
1<= T <= 103
sum of string length <= 105



SAMPLE INPUT
3
1234567890
0123456789
0123456.87
SAMPLE OUTPUT
YES
NO
NO


















Solution to the Problem
using System; 
using System.Numerics;
class MyClass {
    static void Main(string[] args) {
        
string line1 = System.Console.ReadLine().Trim();
var N = Int32.Parse(line1);
string[] arr = new string[N];
 for (var i = 0; i < N; i++)
   {
   arr[i] = Console.ReadLine();
   }
for (var i = 0; i < N; i++)
{
 try
{
var str = (Convert.ToInt64(arr[i]).ToString().Length == 10) ? "YES" :  "NO";
 Console.WriteLine(str); 
 }
 catch
 {
  Console.WriteLine("NO");
 }
 }
 }
}










Wednesday, 19 October 2016

how to remove element.style in css

Hi I am using MVC. i am having a page where a cSS has been added for the title which is in <strong></strong>

I firebug it , it appears as
element.style {
color:#666666;
}
i dont know of from where it comes from..
but i am having a css applied for the same tag with other color. but it disappeared. How to remove the element.style globally..


Solution: 
It is possible to override inline styles from an external stylesheet
strong[style] { color: blue !important; } 
This works in most major browsers, Chrome, Safari, Firefox, IE8
It doesn't work (to my knowledge) in IE6 / IE7

Friday, 22 July 2016

Taleo: Installing Taleo (TCC) Client

This blog is first in my upcoming blogs of Taleo (TCC). In this I would like to show how we can install Taleo Client TCC.



2. Sign in / Register. (OTN SSO username/password will be used)  
3. Select Product "Oracle Taleo Plateform Cloud Service - Connect" and Plateform Window-32

    Select Continue
4. Read and Accept ‘Terms and Conditions’

5. Download TCC Application Datamodel and TCC Application Installer for windows

6. Once downloaded unzip both zip files. They both contains an exe file each.

7. Install ‘Taleo Connect Client Application Data Model (15.1.0.3) for Microsoft Windows.exe’ first. NOTE: its installation location. It will be required in second installation. 

8. Install ‘Taleo Connect Client Application Installer (15.1.0.11) for Microsoft Windows.exe’. Provide pip location as the location of where you installed datamodel.



9. Launch Taleo Client.
10. If you are launching first time, you need to pint Taleo server. Select Product and provide, Host Port (generally 443 for https), username/password

Monday, 11 July 2016

Classes residing in App_Code is not accessible

namespace CLIck10.App_Code
{
    public static class Glob
    {
        ...
    }
}

Right click on the .cs file in the App_Code folder and check its properties.
Make sure the "Build Action" is set to "Compile".

Tuesday, 16 February 2016

Error occurred in deployment step 'Recycle IIS Application Pool'


So you have built a solution in Visual Studio and you use the Deploy option on the Build menu to deploy the solution to your local SharePoint instance for testing. Your solution builds okay, but when you get to the actual deployment step it's just not happening. You might also see "<nativehr>0x80070005</nativehr><nativestack></nativestack>Access denied", or a suggestion to check that you have set the Url correctly and the site collection exists. You're sure you set the Site URL correctly in the project properties. What's going wrong?

What makes this error so confusing is that it talks about recycling IIS, and yet we know we can do an IIS recycle or an IISRESET.
 
The problem here is that the account you are using to run Visual Studio does not have sufficient permissions on the SharePoint site. Several people have suggested fixing this by granting Shell Admin to the account in PowerShell or going into SQL Server and modifying permissions. I have found that by far the easiest fix for this is to go into Central Administration and add the user account that runs Visual Studio (presumably your logged in account) to the site collection administrators by going to Central Administration -> Application Management -> Change site collection administrators. You can also do this through site collection administration (site collection administrators in the ribbon on the Permissions page).

You could try just adding the account as a site owner but you might encounter problems activating features and so on - easier just to add to site collection administrators and be done with it. Obviously this doesn't apply to your test and production environments.

C# LINQ Joins With SQL

There are  Different Types of SQL Joins  which are used to query data from more than one database tables. In this article, you will learn a...