Sunday, October 24, 2010

Unable to connect Database Erwin

Some time we face problems while connecting Erwin to Sql server ,
to resolve the issue

just download ntwdblib.dll and place it into system32 folder.

Tuesday, October 19, 2010

How to find Sql server version

Following query can be used to find which sql server 2005 version is installed .

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Thursday, October 7, 2010

Date Picker in Excel Sheet Column

You can display a calendar control on a user form if you wish. This action may be triggered by right-clicking a cell (my preference) or by selecting it (your request). The code below is activated by selecting a cell in the range A1:A10.




First, you probably need to change your macro security setting. To do so, open the Tools...Macro...Security menu item. Choose Medium, then click OK.





1) ALT + F11 to open the VBA Editor

2) Insert...User Form to create a blank user form

3) Open the Tools...Additional Controls menu item, then scroll down until you find the Microsoft Date and Timer Picker. Make sure to check its box.

4) Back in the user form, click the new DT Picker control on the Forms toolbar, then draw the control on the form

5) Right-click the user form, then choose "View code". Insert the following subs (which assume that your form is called UserForm1 and it contains a calendar control named DTPicker1.



Private Sub DTPicker1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

ActiveCell.Value = UserForm1.DTPicker1.Value

End Sub



Private Sub UserForm_Initialize()

UserForm1.DTPicker1.Value = Date

End Sub



6) ALT + F11 to return to the Excel Worksheet, then right-click the sheet tab and choose "View code" from the resulting pop-up. Paste the following code there:



Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, [A1:A10]) Is Nothing Then Exit Sub



UserForm1.Show

End Sub



7) ALT + F11 to return to the worksheet

Tuesday, October 5, 2010

Running Total Query Sql

We can get running total against fields by using  a self join like

CREATE TABLE #Table


(

Id int,

Name varchar(50),

Length int

)



INSERT INTO #Table (Id, Name, Length)

SELECT 1, 'Field1', 23 UNION ALL

SELECT 2, 'Field2', 34 UNION ALL

SELECT 3, 'Field3', 21 UNION ALL

SELECT 4, 'Field4', 10 UNION ALL

SELECT 5, 'Field5', 5





SELECT F1.Id,f1.Name,f1.Length,ISNULL(SUM(F2.Length),0) AS RunTotal FROM #Table F1

LEFT JOIN #Table F2 ON f1.Id - 1 >=f2.Id

GROUP BY F1.Id,F1.Name,f1.Length