faizan ahmad

Usually the things which were not a straight Google

  Home  |   Contact  |   Syndication    |   Login
  17 Posts | 0 Stories | 68 Comments | 0 Trackbacks

News

Archives

Post Categories

.NET

ASP.NET

SQL Server

Presumption/limitation: yearly holidays are stored in a table maximum 2 consecutive holidays Table structure: HOLIDAY_DATE (DATETIME),HOLIDAY_DESC (VARCHAR) DB Script : DECLARE @CurrentDay DATETIME DECLARE @LastWorkingDay DATETIME, @CurrentWeekDay INT SET @CurrentDay = CAST(CONVERT(VARCHAR, GETDATE(), 101) AS DATETIME) SET @LastWorkingDay = CAST(CONVERT(VARCHAR, GETDATE(), 101) AS DATETIME) DECLARE @DaysToLastWorkingDay INT SET @DaysToLastWorkingDay = 0 SET @LastWorkingDay = DATEADD(day, -1, @LastWorkingDay ......

Quite Straight forward: Select the Column , Right Click -> Propoerties OR hit F4 Visibility -> Hidden -> Expression i.e. Click on Hidden under Visibility and select Expression from Drop Down Write the expression e,g. =IIF(Parameters!MonthlyOrYe... ......

compared to FormatDateTime Good old 'Format' function makes the job a lot easier : Format(Fields!ResultDate.Va... Format(Fields!ResultDate.Va... =IIF(Parameters!MonthlyOrYe... ......

"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression" As the error message suggests , this normally occurs when you are assigning a T-SQL variable a value within sql query and the query is returning more that one rows e.g. Declare @var1 nvarchar(50) ' select @var1=name from table1' Putting 'top 1' can resolve the problem in many cases ( do check the business logic aspects): ' select top ......

It s really easy to debug a SQL sever stored procedure in Visual Studio, here are the steps: Open Server Explorer Connect to the Database which have the stored procedure that you want to debug Once you are connected to a DB, it will display DB objects in Server Explorer, Click to expand Stored Procedures Right Click on the Stored Procedure ( that you want to debug ) Click on 'Step Into Stored Procedure' ......

I had to update value from a staging table( this might be a temp table ) into another database table. Here is how I did it using a inner join in the Update statement. UPDATE Table1 SET Table1 . Field1 = StagingTable . Field1 FROM Table1 INNER JOIN StagingTable ON Table1 . Field2 = StagingTable . Field2 WHERE StagingTable . Field3 IS NOT NULL ---------------------------... way we can use JOINs in delete statementsSyntax for join in Delete is a bit different ......