Case statement in MongoDB query - aggregation
Using $cond (aggregation) we can perform case statement in MongoDBSQL query: SELECTfName,lName,(CASEWHENtotalOrder> 70 THEN'Golden'ELSE'Silver'END)ASUserType FROMdbo.UsersIn above query I am trying...
View ArticleDifference between MVC3, MVC4, MVC5, MVC6
Microsoft has added exciting features in every new version of ASP.NET MVC that make developers more comfortable building scalable web applications easily. In this ASP.NET MVC tutorial, we will have a...
View ArticleWhat is the difference between DATEFIRST and @@DATEFIRST in SQL Server
DATEFIRST keyword use to reset first day of week in SQL Server and @@DATEFIRST return the current value for the session of DATEFIRST.For Example:-As we know SQL Server set default language US English...
View ArticleHow to identify open transactions in SQL Server
There are many way to find open transaction which are not COMMIT or ROLBACK.Below script may help you to find out open TRANSACTION in SQL Server1. Using SYS.SYSPROCESSES...
View ArticleCase sensitive search on column in SQL Server
Suppose we have a table #TBL with column SEARCH_CONTENT which have values like 'DILIP SINGH', 'dilip singh' and 'Dilip Singh' like below. CREATETABLE #TBL( ID INTIDENTITY(1,1), SEARCH_CONTENT...
View ArticleAdd a column, with a default value, to an existing table in SQL Server
You can do it by edit of table design, if you want do it with query see following.Syntax: ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT...
View ArticleHow to check if column exists in SQL Server table
Following Query may help you to check existing column in SQL server.If Not Exists (SELECT Column_Name FROM sys.columns WhereTable_Name = Tbl_Name...
View ArticleWhat is the difference between char, nchar, varchar, and nvarchar in SQL Server
nchar and nvarchar can store Unicode characters. char and varchar cannot store Unicode characters.char and nchar are fixed-length which will reserve storage space for number of characters you specify...
View ArticleDynamic PIVOT query in SQL Server
Problem: Suppose we have a table TMP where we keep the data of Representatives like RepName, NumberOfLead, Date etc. as below Now we have to show data like below. Answer: Very easy we can use PIVOT...
View ArticleHow to connect to SQL Server database from JavaScript
How to connect to SQL Server database from JavaScriptUsing javascript to access databases may harmful for several reasons like bad practice, security issues, etc.. here is an example given below:var...
View ArticleTurning a Comma Separated string into individual rows in SQL Server
Problem: A column have string comma separated value as below.We need result like as belowAnswer: See following query it may help you..CREATETABLE#TMP(IDINT,NAMEVARCHAR(MAX))INSERT#TMPSELECT...
View ArticleTruncate or Shrink a SQL Server log file
Many way you can shrink the log file, some trick is given below.1. Management studio:Don't do this on a live environment, but to ensure you shrink your dev db as much as you can:Right-click the...
View ArticleGridFS in MongoDB
GridFSGridFS is responsible for storing and retrieving files, GridFS store file in single document and divides a file into parts, or chunks and stores each or those chunks as a separates document. By...
View ArticleGridFS Index in MongoDB
GridFS IndexUnique and compound index used by GridFS on chunks collection for the files _id and n fields. _id field contains the _id of the chunk's "parent" document and the n filed contains the...
View ArticleHow to list all collections in the MongoDB
getCollectionNames() Function use to list all collections in MongoDB.Syntaxdb. getCollectionNames()it will return all the collection from db.Exampledb.getCollectionNames()Output[ "collection1",...
View ArticleHow do you rename a MongoDB database
Even I did not find any command to rename database directly.To rename database please track following steps.1- Copy your old database to new renamed database....
View ArticleAggregation Pipeline Operators in MongoDB
To retrieve data according to user MongoDB provide aggregate operators, using this operators we can reshape array, sort the records, filter the records etc. Pipeline stages appear in an array....
View ArticleHow can I Update top 10 records in SQL Server
Hello guys suppose we have to update top 10 records in table, the following query may help you..CREATETABLE #TMP(ID INTIDENTITY(1,1),NAME VARCHAR(100),SALARY DECIMAL(16,2))INSERTINTO...
View ArticleDropdownlist selectedindexchanged event is not firing
<asp:DropDownList ID="ddlSource" runat="server" DataSourceID="SqlDataSource1" DataTextField="vcSuplierNm" ViewStateMode="Enabled DataValueField="vcSuplierCode" EnableViewState="true"...
View ArticleMarking a stored procedure as system object in SQL Server
Once my friend ask to me, It is possible to mark a stored procedure as system object allow to run in user database context? I said yes we can do. We have to follow two step which is mention below.Step...
View Article