Tuesday, 10 May 2011

SQL Search for a String in all Tables

Declare @TN as varchar(200), @CN as varchar(200), @myValue varchar(30), @SQL as nvarchar(1000) 
, @SN as varchar(200), @Exact_Match bit 
  
Create Table #myTable (Table_Name varchar(200), Column_Name varchar(200), Number_Of_Rows int) 
  
-- Replace @myValue with the value you're searching for in the database 
Set @myValue = 'mySearchValue'  
-- 0 for LIKE match, 1 for exact match 
Set @Exact_Match = 0     
  
Declare myCursor Cursor For 
Select T.Table_Name, C.Column_Name, T.Table_Schema 
From INFORMATION_SCHEMA.TABLES T Inner Join INFORMATION_SCHEMA.COLUMNS C  
On T.Table_Schema = C.Table_Schema And T.Table_Name = C.Table_Name 
Where T.Table_Name Not In ('dtproperties') And Table_Type = 'Base Table' 
And C.Data_Type In ('varchar','char','nvarchar','nchar','sql_variant') 
--And C.Data_Type In ('text','ntext') 
--And C.Data_Type In ('tinyint','int','bigint','numeric','decimal','money','float','smallint','real','smallmoney') 
--And C.Data_Type In ('datetime','dmalldatetime') 
-- Fields not searched: image, uniqueidentifier, bit, varbinary, binary, timestamp 
Open myCursor 
Fetch Next From myCursor Into @TN, @CN, @SN 
While @@Fetch_Status <> -1 
Begin 
        If @Exact_Match = 0 
                Set @SQL = N'Insert Into #myTable Select ''' + @SN + '.' + @TN + ''', ''' + @CN + ''', Count(*) From [' + @SN + '].[' + @TN + '] Where [' + @CN + '] Like ''%' + @myValue + '%''' 
            Else 
                Set @SQL = N'Insert Into #myTable Select ''' + @SN + '.' + @TN + ''', ''' + @CN + ''', Count(*) From [' + @SN + '].[' + @TN + '] Where [' + @CN + '] = ''' + @myValue + '''' 
        --Print @SQL 
        Exec sp_executesql @SQL  
        Fetch Next From myCursor Into @TN, @CN, @SN 
End 
Close myCursor 
Deallocate myCursor 
Select * From #myTable Where Number_Of_Rows > 0 Order By Table_Name 
Drop Table #myTable

Thursday, 5 May 2011

SSRS 2008 Report String Filter with LIKE operator

goto the Filters in Tablix or Group,
Add the filter,
select Expression as your Fieldname to be filtered on,
select operator LIKE
in value when you click fx button it will show you options in new window
click parameters and select the parameter you created in the report.
you'll see =Parameters!ParameterName.Value
change that to = "*" & Parameters!ParameterName.Value & "*"

SSRS 2008 Paging shows Question mark (?)

Yes I got confused as well as to what this suddenly a new thing in SSRS 2008 and how to solve it, I even thought its a bug, but guess what, its a feature Microsoft has introduced question mark is there because report did not render all the pages and only current page worth of records were processed, it is called On Demand Report Processing.



Yes I do understand the potential of massive performance gains but lets be honest whats the point of showing Page 1 of 2? its not really helpful.

Here we go, you will have to add a little piece of code in your report, so add a textbox in your header or footer containing =Globals!TotalPages, please note that its only allowed in the header or footer, and then you'll see that report will show current number of pages.




 

Tuesday, 3 May 2011

Appraisal vs Resignation

A newly joined trainee asks his boss "what is the meaning of appraisal?"
Boss: "Do you know the meaning of resignation?"
Trainee: "Yes I do"

Boss: "So let me make you understand what a appraisal is by comparing it with resignation"

Comparison study: Appraisal and Resignation Appraisal

In appraisal meeting they will speak only about your weakness, errors and failures.
In resignation meeting they will speak only about your strengths, past achievements and success.

In appraisal you may need to cry and beg for even 10% hike.
In resignation you can easily demand (or get even without asking) more than 50-60% hike.

During appraisal, they will deny promotion saying you didn't meet the expectation, you don't have leadership qualities, and you had several drawbacks in our objective/goal.
During resignation, they will say you are the core member of team; you are the vision of the company how can you go, you have to take the project in shoulder and lead your juniors to success.

There is 90% chance for not getting any significant incentives after appraisal.
There is 90% chance of getting immediate hike after you put the resignation.

Trainee: "Yes boss enough, now I understood my future. For an appraisal I will have to resign..!!

Friday, 25 March 2011

Create Azure asp.net site using Web Role

Create new project using Cloud Template (Windows Azure Project)


Press OK wizard will show you different types of roles, seleect ASP.NET Web Role and add


Press OK


Wizard has created a Project which has Azure Cloud Web Role


When you press F5 or start debug, you'll notice Windows Azure Emulator on your taskbar.


Right click and select Show Compute Emulator UI


You'll be able to see your project being executed


Not much to do here :) just add your files and you are good to go.

Monday, 7 March 2011

Create Event Handler in SharePoint with Visual Studio 2010

Working with the new Visual Studio 2010 has become so easy that even I can write my own event handlers within no time. Traditionally you'll go thru alot of pain of writing classes, creating features, and then deploying and activation of those features.

here you go in simple steps:

first create new project, by selecting the SharePoint Event Receiver project type.


Enter the site for debugging your code and select deploy as a farm solution



Select the List Item Events type, for Announcements (e.g.) for an item is being deleted


Write your code to handle whatever you want to achieve.


You can build the project, or just simply deploy it to your site if you are sure there are no errors.



Now sit back and relax Visual Studio 2010 will do all the work for you, and deploy the project into correct areas and do whatever is required to be done such as snk, .wsp, web.config, feature activation etc etc.


Now the moment of truth, i'll try to delete an announcement from my site 


and there you go the code has worked, (i don't know how hahaha)





if you notice in your project you had an xml file Elements.xml it has a ListTemplateID="104", here is the list of all id(s) which you might need.

100   Generic list
101   Document library
102   Survey
103   Links list
104   Announcements list
105   Contacts list
106   Events list
107   Tasks list
108   Discussion board
109   Picture library
110   Data sources
111   Site template gallery
112   User Information list
113   Web Part gallery
114   List template gallery
115   XML Form library
116   Master pages gallery
117   No-Code Workflows
118   Custom Workflow Process
119   Wiki Page library
120   Custom grid for a list
130   Data Connection library
140   Workflow History
150   Gantt Tasks list
200   Meeting Series list
201   Meeting Agenda list
202   Meeting Attendees list
204   Meeting Decisions list
207   Meeting Objectives list
210   Meeting text box
211   Meeting Things To Bring list
212   Meeting Workspace Pages list
301   Blog Posts list
302   Blog Comments list
303   Blog Categories list
1100   Issue tracking
1200   Administrator tasks list

Friday, 4 March 2011

GUID Generation

If you want to create a GUID for your project follow the procedure.


  1. Open the Visual Studio .NET Command Prompt.

    In the Program Group for Visual Studio .NET, point to Visual Studio .NET Tools and choose Visual Studio .NET Command Prompt. A command prompt will be displayed. This special command prompt window allows you to access tools for Visual Studio.
  2. Launch the GUID Generator.
    At the command prompt, enter the following:

    guidgen

    The Create GUID utility will appear.
  3. Specify the type of GUID to generate.
    The Create GUID utility can generate GUIDs in several forms. For Business Portal integrations, GUIDs must be in the Registry format.
  4. Generate and copy the GUID.
    To generate a new GUID, click New GUID. To copy the GUID to the clipboard to use in your integration, click Copy.