Posts

Show animated wait window ,while processing request

Its a major problem faced while processing DB request else functions etc . The problem is when we perform command on database it takes time of few seconds, at that time my applications main window becomes halted. when i performs command on database execution returns on main application when whole command is executed on database. Just Like "NonQuery()" Lets assume we are working on asp.net 4.0 and sending request to view.  i am showing a form before it and closing that form after the command, but problem is i am putting a GIF image on the form, because exection is halted on main application, the gif don't shows animation until the command is executed. so that i putted it on a BackGroundWorker, but main thread is halted so its child tread also become halt. we can not put database transaction in background worker, becuase sometime working is depended on result retrieved from database, and we want to halt application untill data is not fetched, but in this case ...

Dynamic query in SQL

Dynamic query which nothing but conditional query which help to optimize query and improve performance of query. Currently using   [AdventureWorksLT2008R2] datbase as following : Try first EXEC ('SELECT * FROM SalesLT.Product') You can try following just for idea DECLARE @SQL NVARCHAR(max), @ParmDefinition NVARCHAR(1024) DECLARE @ListPrice money = 2000.0, @LastProduct varchar(64) SET @SQL =       N'SELECT @pLastProduct = max(Name)                    FROM SalesLT.Product                    WHERE ListPrice >= @param1' SET @ParmDefinition = N'@param1 money,                         @pLastProduct varchar(64) OUTPUT' EXECUTE sp_executeSQL      -- Dynamic T-SQL             @SQL,             @ParmDefin...

Paging in SQL Server

Image
Paging is one the functionality which we can achieved in many ways. So many plugins,technologies used for development. My sir already used in 2008, I think over to tried it in by different way. It found that Microsoft provides pagination feature with SQL Server 2012. We can acheived it by row_number() and minimum ids etc But from SQL Server 2012 we can do pagination by using FETCH and OFFSET. From above records, I need to split next 6 records after 32 Address ID. So doing pagination is a two-step process: - First mark the start of the row by using “OFFSET” command. Second specify how many rows you want to fetch by using “FETCH” command. Query :  1. Fetching records from 0 to above SELECT * FROM [Address]  order by AddressID offset 0 rows – start from zero Fetch Next 6 Rows only 2. Fetching records from 32 to next 6 records paging. SELECT * FROM [Address]  order by AddressID offset 6 rows  Fetch Next 6 Rows only [...

NIHAR'S BLOG: Sequence : Auto Generated ID's in SQL Server 2012

NIHAR'S BLOG: Sequence : Auto Generated ID's in SQL Server 2012 : Hi friends , after long time come back with new excellent features of SQL Server 2012. Don't worry , I am not posting all features bec...

Reading text file in SQL Server

There are many option to read text file data and store it into database. We may have following options available for reading/storing/updating data into database 1.  Import and Export wizard of SQL Serve 2. SQL Server Integration Services 3. Using C# with SQL CLR will insert data into tables But , using few lines code of query need to execute in SSMS. SQL Server provides  " BULK INSERT "  Operation to read data from local system and store it into database tables. Steps : 1. First create text file with some name "Abc.txt" and enter values as nihar, Vishal, Vivek, Save and Copy path of file. 2. Open SSMS and create temp table for data insertion Create table temp_Data ( name nvarchar(20) ) 3.  Use following query to view operation BULK INSERT  Temp_data FROM   'D:\Abc.txt' WITH ( FIELDTERMINATOR  = ',' ,     -- Here you can use any delimiter for seperation ROWTERMINATOR  = '\n'   ); SELECT * FROM ...

Packages in PL/SQL

Brief :        "Packages" word only come up with Oracle PL/SQL. As Microsoft fan , googling about " Packages in SQL Server ".. Actually their will be no dependency on that ..(LOLzz) Example: We are working on huge database , or rapid increases of Stored procedures , functions etc ( proliferation) . It will be difficult to manage it. Packages can save time to describe procedure / function schema. What is Packages in Oracle ? If you observed any document related to Packages , let you know about "Interface in OOP" and if you search packages in SQL Server,you will get references related to SSIS , Data flow , control flow  etc. (I am also beginner to all this..) Some advantages tells that , why you need it ? I found packages to be really useful for a number of reasons: All the procedures and functions relating to a specfic sub-system are in one program unit. This is just good design practice but it's also easier to manage, e.g. in sourc...

Sequence : Auto Generated ID's in SQL Server 2012

Hi friends , after long time come back with new excellent features of SQL Server 2012. Don't worry , I am not posting all features because I have started reading it one by one.So need your support for more understandings.I know ,after this post my team members will help to understand and help to implement it. UI : More rich experience like WPF of Visual Studio and good performance than R2 Sequences   : Auto generated ID's Sequences, unlike identity columns, are not associated with specific tables. Applications refer to a sequence object to retrieve its next value. The relationship between sequences and tables is controlled by the application. User applications can reference a sequence object and coordinate the values across multiple rows and tables. Use sequences instead of identity columns in the following scenarios: The application requires a number before the insert into the table is made. The application requires sharing a single series of numbers between mul...