Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Finding Max values of column for all the tables for SQL Server

leave a comment »

 

DECLARE @DatabaseName VARCHAR(100)
DECLARE @SchemaName VARCHAR(100)
DECLARE @TableName VARCHAR(100)
DECLARE @ColumnName VARCHAR(100)
DECLARE @FullyQualifiedTableName VARCHAR(500)
DECLARE @DataType VARCHAR(50)

–Create Temp Table to Save Results
IF OBJECT_ID(‘tempdb..#Results’) IS NOT NULL
    DROP TABLE #Results

CREATE TABLE #Results (
    DatabaseName VARCHAR(100)
    ,SchemaName VARCHAR(100)
    ,TableName VARCHAR(100)
    ,ColumnName VARCHAR(100)
    ,ColumnDataType VARCHAR(50)
    ,MaxValue VARCHAR(50)
    ,MinValue VARCHAR(50)
    )

DECLARE Cur CURSOR
FOR
SELECT DB_Name() AS DatabaseName
    ,s.[name] AS SchemaName
    ,t.[name] AS TableName
    ,c.[name] AS ColumnName
    ,'[‘ + DB_Name() + ‘]’ + ‘.[‘ + s.NAME + ‘].’ + ‘[‘ + T.NAME + ‘]’ AS FullQualifiedTableName
    ,d.[name] AS DataType
FROM sys.schemas s
INNER JOIN sys.tables t ON s.schema_id = t.schema_id
INNER JOIN sys.columns c ON t.object_id = c.object_id
INNER JOIN sys.types d ON c.user_type_id = d.user_type_id
WHERE  is_identity = 1 –and WHERE i.is_primary_key = 1

OPEN Cur

FETCH NEXT
FROM Cur
INTO @DatabaseName
    ,@SchemaName
    ,@TableName
    ,@ColumnName
    ,@FullyQualifiedTableName
    ,@DataType

WHILE @@FETCH_STATUS = 0
BEGIN
    DECLARE @SQL VARCHAR(MAX) = NULL

    SET @SQL = ‘ Select ”’ + @DatabaseName + ”’ AS DatabaseName, ”’ + @SchemaName + ”’ AS TableName,
      ”’ + @TableName + ”’ AS SchemaName,
      ”’ + @ColumnName + ”’ AS ColumnName,
      ”’ + @DataType + ”’ AS ColumnName,
      (Select MAX(‘ + @ColumnName + ‘) from ‘ + @FullyQualifiedTableName + ‘ with (nolock))
      AS MaxValue,
      (Select MIN(‘ + @ColumnName + ‘) from ‘ + @FullyQualifiedTableName + ‘ with (nolock))
      AS MaxValue’

    PRINT @SQL

    INSERT INTO #Results
    EXEC (@SQL)

    FETCH NEXT
    FROM Cur
    INTO @DatabaseName
        ,@SchemaName
        ,@TableName
        ,@ColumnName
        ,@FullyQualifiedTableName
        ,@DataType
END

CLOSE Cur

DEALLOCATE Cur

SELECT *
FROM #Results
order by TableName
    –drop table #Results

Written by Manish

November 1, 2017 at 2:57 pm

Posted in SQL Server

221 See you later with sendgrid.net

leave a comment »

We are using sendgrid to send the emails to customers. Just yesterday, got the issues and when analyzed log, we could see 221 and 421 error with sendgrid.

The issue was the slow connection with sendgrid and due to the same, it return the error. Checked ping and tracert to smtp.sendgrid.net and getting very slow response.

Written by Manish

June 29, 2016 at 3:46 pm

Posted in Uncategorized

Create Temporary Table in SQL Server

leave a comment »

if you Wanted to create temporary tables without create and all stuff.

Solutins:

Select * into #TEMPTABLENAME from TABLE

Written by Manish

September 7, 2013 at 4:47 pm

Posted in SQL Server

Magic Disk – Virtual Drive for ISO Mount

leave a comment »

Just found alternative for Magic Disk

GBurner Virtual Drive

OSFMount

Written by Manish

June 23, 2013 at 8:29 pm

Posted in Tools

Tagged with ,

550 Cannot receive from specified address : Unauthenticated senders not allowed in SendGrid

leave a comment »

I received this while working with SendGrid. The issue was, we are not using Authentication before sending emails. Just set it up in our code and it works like charm.

Written by Manish

June 22, 2013 at 5:10 pm

Posted in .NET, .NET 4.0, ASP.NET

Tagged with ,

Important features of MVC4

leave a comment »

A few important updates and features of MVC4.

  • Bundling and Minification, brought to ASP.NET 4.5 and now also integrated into ASP.NET MVC 4. This allows you to build faster applications by minimizing the number of requests to the server (bundling requests).
  • Web API integration into ASP.NET: new support for creating HTTP REST services, has built-in support for content negotiation with support for JSON, XML and Form URL-encoded formats
  • ASP.NET Mobile support through custom view engines for mobile sit.es and jQuery Mobile integration.
  • Async and WebSockets: when using ASP.NET MVC 4 with .NET 4.5 and VS 11 you’ll also be able to take advantage of the new async and WebSocket support built-into .NET 4.5.
  • Single Page Applications: new in the beta is support for building better end-to-end experience for building applications with client-side interactions using JavaScript (Upshot, History.js) and the MVVM pattern (knockout.js). On the server side the ASP.NET NET Web API is used, mainly an abstract class DataController. Note this is a new project template type in experimental phase.
    For more information on creating Single Page Applications with ASP.NET MVC 4 I recommend you watch the fantastic session Steve Sanderson did during TechDays: Building rich Single Page Applications (SPAs) for desktop, mobile, and tablet with ASP.NET MVC 4. Worth watching until the end where Steve even shows an offline capable implementation using HTML5 application cache and offline storage. These latter ones however are not yet part of the beta.

    source

Written by Manish

July 21, 2012 at 5:03 am

GTD Application Comparision

leave a comment »

Following are the GTD tasks list software comparison for android

 

Written by Manish

April 8, 2012 at 7:55 pm

Posted in Uncategorized

Tagged with ,

Should I buy from RightGadgets.in? A BIG NO

with one comment

Hi all,

This is just to aware you about the worst shopping experience I had with the website that is RightGadgets.in. There are many site from which I have been purchasing since last 5 years and thought to try on RightGadgets.in. I made an order with RightGadgets.in and after 10 days there are no reply back for the order I placed. Then when I get back to them using contact email, they just tell me following, Following is reply from Virendra Baradia

 
 

Tuesday, 23 August 2011 1:20 PM

Message Body

Dear sir,

Due to unavailability of stock your order is cancelled with us. We had sent a mail to you but I guess it had gone on a wrong id hence it bounced back. We sincerely regret the inconvenience caused for the same.

From: Manish Pansiniya [mailto:manish_ld@yahoo.com]
Sent: Monday, August 22, 2011 11:22 PM
To: contact@rightgadgets.in
Cc: Rightgadgets@rightflorist.co.in
Subject: Re: Rightgadgets Your Order No.: CRRGI-201108101

Could you please let me know the status of my order.

Thanks,

Manish

 

I have purchased with many sites and I thought to experience new website but the issue is they are not mature enough to have good customer experience. I suggest you to purchase from

– Ebay
– IndiaPlaza
– Infybeam
– Tradus

And for RightGadgets.in…A BIG NO..Don’t go with it.

Written by Manish

August 23, 2011 at 4:41 pm

IE9–Increase last Visited Websites in Address bar

with one comment

The default settings of IE9 has only 5 last visited websites and that sometimes irritates user as they could not select website that we visit daily. It looks something like this:

image

If we want to view this list fully, we need to change following settings:

Goto IE9 > Internet Options > Content Tab > AutoComplete and uncheck all the items below address bar. Keep addressbar checked.

image

That’s it!!!. It will show entire list of site.

Written by Manish

August 12, 2011 at 10:45 pm

Outlook Addins

leave a comment »

Good Source of outlook addins

http://www.codetwo.com/downloads/freeware/

Written by Manish

August 12, 2011 at 12:03 am

Posted in Outlook, Tools

Tagged with ,