Posts

DROP Tables and Procedures Using MS SQL Server

DROP Tables and Procedures Using MS SQL Server -- query to get all Tables DECLARE @sql NVARCHAR(max)='' SELECT @sql += ' DROP PROCEDURE  ' + QUOTENAME(TABLE_SCHEMA) + '.'+ QUOTENAME(TABLE_NAME) + '; ' FROM   INFORMATION_SCHEMA.PROCEDURES WHERE  TABLE_TYPE = 'BASE TABLE' SELECT @SQL  -- after executing the below query, All tables will dropped. EXEC Sp_executesql @sql -- query to get all procedures SELECT 'DROP PROCEDURE [' + SCHEMA_NAME(p.schema_id) + '].[' + p.NAME + '];' FROM sys.procedures p 

Microsoft SQL Server old and new versions

Major Version / Compatibility Level Version Label File Version 80 SQL Server 2000 8.00.xxxx 90 SQL Server 2005 9.00.xxxx 100 SQL Server 2008 10.00.xxxx 105 SQL Server 2008 R2 10.50.xxxx 110 SQL Server 2012 11.00.xxxx 120 SQL Server 2014 12.00.xxxx 130 SQL Server 2016 13.00.xxxx 140 SQL Server 2017 14.00.xxxx 150 SQL Server 2019 15.00.xxxx 160 SQL Server 2022 16.00.xxxx  

Table Variable in MS SQL Server

1. Syntax: DECLARE @T TABLE (...) 2. A Table variable is also created on disk in the tempDB system database. But the name of this table variable is generated completely by the SQL engine and it also differs from other similar named tables created in the same or other sessions.                -  check with the below query          select*from tempdb. INFORMATION_SCHEMA.tables 3. A Table Variable is created in memory, this is a myth. They are also treated as Temp-Tables and created in tempdb but they perform slightly better than temp-tables because there is even less locking and logging in a table variable. 4. Table variables are the only way you can use DML statements (INSERT, UPDATE, DELETE) on temporary data within a UDF (User Defined Function). You can create a Table Variable within a UDF, and modify the data using one of the DML Statements, this is not possible with temp-tables.  5. A Table variable ...

Error on renaming database in SQL Server 2008 R2

Error on renaming database in SQL Server 2008 R2 use master ALTER DATABASE OldDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE     ALTER DATABASE  OldDatabaseName  MODIFY NAME = [New_DatabaseName] ALTER DATABASE  New_DatabaseName  SET MULTI_USER Notes:  you should use  WITH ROLLBACK IMMEDIATE  while altering a database that other users might be operating on, in order to ensure the integrity of these operations. But it is not really necessary when setting the database back to MULTI_USER mode again since the database is already at SINGLE_USER mode and you are the only user able to run any transactions anyway.

Convert Viewmodel to JSON string using C#, convert json string to JSON Format using C#

//CONVERT POST PARAMETERS INTO JSON-SERIALIZE var json = JsonConvert.SerializeObject(model); // Convert Json String to JSON Format in C# dynamic responseData = Newtonsoft.Json.Linq.JObject.Parse(_responseData);

Accessed JArray values with invalid key value. Array position index expected

Accessed JArray values with invalid key value: “fields”. Array position index expected  ========================================================== { "response" :{ "status" : "ok" , "userTier" : "approved" , "total" : 1 , "startIndex" : 1 , "pageSize" : 10 , "currentPage" : 1 , "pages" : 1 , "orderBy" : "newest" , "results" :[{ "id" : "sustainable-business/sustainable-finance-where-next-open-thread" , "sectionId" : "sustainable-business" , "sectionName" : "Guardian Sustainable Business" , "webPublicationDate" : "2014-02-13T13:27:00Z" , "webTitle" : "Where next for sustainable finance? - open thread" , "webUrl" : "http://www.theguardian.com/sustainable-busi...

The Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine

Image