Showing posts with label SQL SERVER. Show all posts
Showing posts with label SQL SERVER. Show all posts
Wednesday, August 19, 2020
Wednesday, August 5, 2020
SQL Server Stretch Database
Stretch Database
Data can be split between on-premises and cloud storage.
With Stretch Database, cold/audit data is kept in the cloud and data remains available for users to
query, might be a small amount of additional latency associated with queries. Data in the cloud is backed up automatically.
With Stretch Database, active data is kept on-premises for maximum performance and reduce storage requirements both for data and backups (it run quicker than standard backups).
It requires no changes to new or existing TSQL queries.
Wednesday, March 30, 2016
MS Dynamics CRM - Display Unique/Auto Number on the form before save.
My client requirement is display the unique reg number for new contact before the save record.
My Previous blog <a href="http://makdns.blogspot.com/2016/03/ms-dynamics-crm-generate-uniqueauto.html">MS Dynamics CRM - Generate Unique/Auto Number</a> will show the reg number on form after save the new contact. if the user clicks save and close, they can't see the number.
So i come up with the web service concept to generate unique number for new contact and display on the contact screen.
Also i am using SQL Server sys.sequences for generating new number.
Web Service Code
My Previous blog <a href="http://makdns.blogspot.com/2016/03/ms-dynamics-crm-generate-uniqueauto.html">MS Dynamics CRM - Generate Unique/Auto Number</a> will show the reg number on form after save the new contact. if the user clicks save and close, they can't see the number.
So i come up with the web service concept to generate unique number for new contact and display on the contact screen.
Also i am using SQL Server sys.sequences for generating new number.
Web Service Code
Monday, June 16, 2014
SQL Server - Common Table Expressions (CTE)
It's a temporary result set that is defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. It is not stored as an object and lasts only for the duration of the query. A CTE can be self-referencing and can be referenced multiple times in the same query.
Syntax
WITH expression_name [ ( column_name [,...n] ) ]
AS
( CTE_query_definition )
SELECT <column_list> FROM expression_name;
Multiple cTE
WITH expression_name1 [ ( column_name [,...n] ) ],
expression_name2 [ ( column_name [,...n] ) ]
select <column_list> FROM expression_name1
union all
select <column_list> FROM expression_name2
select <column_list> FROM expression_name1 en1 inner join expression_name2 en2 on en1.column_name= en2.column_name
Syntax
WITH expression_name [ ( column_name [,...n] ) ]
AS
( CTE_query_definition )
SELECT <column_list> FROM expression_name;
Multiple cTE
WITH expression_name1 [ ( column_name [,...n] ) ],
expression_name2 [ ( column_name [,...n] ) ]
select <column_list> FROM expression_name1
union all
select <column_list> FROM expression_name2
select <column_list> FROM expression_name1 en1 inner join expression_name2 en2 on en1.column_name= en2.column_name
SQL Server - Shortcut to add alias for all the columns
In SSMS, for example
I have a sql query,
now i added alias Sales.SalesPerson sp, want to apply alias name to all the columns quickly, press ALT+Shift button and hold them down while i move my cursor to the lower right of the block.
Now i change to SalesPerson alias name to all column name

I have a sql query,
now i added alias Sales.SalesPerson sp, want to apply alias name to all the columns quickly, press ALT+Shift button and hold them down while i move my cursor to the lower right of the block.
Now i change to SalesPerson alias name to all column name

select
SalesPerson.BusinessEntityID,
SalesPerson.Bonus,
SalesPerson.SalesYTD,
SalesPerson.SalesLastYear
from
Sales.SalesPerson
SalesPerson.BusinessEntityID,
SalesPerson.Bonus,
SalesPerson.SalesYTD,
SalesPerson.SalesLastYear
from
Sales.SalesPerson
SQL Server Last executed query history
SELECT
deqs.last_execution_time AS [Time],
dest.TEXT AS [Query]
FROM
sys.dm_exec_query_stats
AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY
deqs.last_execution_time DESC
http://msdn.microsoft.com/en-us/library/ms188068.aspx
Monday, May 6, 2013
Microsoft Dynamics CRM – Exporting more than 10,000 rows to Excel
Log into SQL Management Studio, OPEN CRM Database
update OrganizationBase set MaxRecordsForExportToExcel = 30000 where OrganizationId = ‘GUID of your organization’
Update through XRM
Organization organization = new Organization();
organization.Id = “your org id”;
organization.MaxRecordsForExportToExcel = 30000;
service.Update(organization);
Dynamics CRM - Change Contact Name Format
UPDATE contactbase SET fullname = ISNULL(lastname, ”) + ‘, ‘ + ISNULL(firstname, ”)
import file is too large to upload
UPDATE ServerSettingsProperties SET IntColumn =15 where columnname=‘ImportMaxAllowedFileSizeInMB’
Increase Grid Page Limit
Open the UserSettingsBase table, change the PagingLimi.
import file is too large to upload
UPDATE ServerSettingsProperties SET IntColumn =15 where columnname=‘ImportMaxAllowedFileSizeInMB’
Increase Grid Page Limit
Open the UserSettingsBase table, change the PagingLimi.
Wednesday, March 13, 2013
SQL Server Shrink Log File
SELECT name,recovery_model_desc FROM sys.databases
GO
Step 1
ALTER DATABASE <Your Database Name> SET RECOVERY SIMPLE;
ALTER DATABASE WSS_Proposal_Content SET RECOVERY SIMPLE;
Step 2
DBCC SHRINKFILE (<Your Database Name>_log, 5);
DBCC SHRINKFILE (WSS_Proposal_Content_log, 5);
Step3
ALTER DATABASE <Your Database Name> SET RECOVERY FULL;
ALTER DATABASE WSS_Proposal_Content SET RECOVERY FULL;
Database 1
Alter database SharePoint_Config set Recovery simple
GO
USE [SharePoint_Config]
GO
DBCC SHRINKFILE (N'SharePoint_Config_log' , 50)
go
Alter database SharePoint_Config set Recovery full
GO
Database 2
Alter database WSS_SESProposal_Content set Recovery simple
GO
USE [WSS_SESProposal_Content]
GO
DBCC SHRINKFILE (N'WSS_SESProposal_Content_log',50)
go
Alter database WSS_SESProposal_Content set Recovery full
GO
Database 3
Alter database WSS_Search_Content set Recovery simple
GO
USE [WSS_Search_Content]
GO
DBCC SHRINKFILE (N'WSS_Search_Content_log',50)
go
Alter database WSS_Search_Content set Recovery full
GO
Find Logical File Name
Declare @LogFileLogicalName sysname
select @LogFileLogicalName=Name from sys.database_files where Type=1
print @LogFileLogicalName
GO
Step 1
ALTER DATABASE <Your Database Name> SET RECOVERY SIMPLE;
ALTER DATABASE WSS_Proposal_Content SET RECOVERY SIMPLE;
Step 2
DBCC SHRINKFILE (<Your Database Name>_log, 5);
DBCC SHRINKFILE (WSS_Proposal_Content_log, 5);
Step3
ALTER DATABASE <Your Database Name> SET RECOVERY FULL;
ALTER DATABASE WSS_Proposal_Content SET RECOVERY FULL;
Database 1
Alter database SharePoint_Config set Recovery simple
GO
USE [SharePoint_Config]
GO
DBCC SHRINKFILE (N'SharePoint_Config_log' , 50)
go
Alter database SharePoint_Config set Recovery full
GO
Database 2
Alter database WSS_SESProposal_Content set Recovery simple
GO
USE [WSS_SESProposal_Content]
GO
DBCC SHRINKFILE (N'WSS_SESProposal_Content_log',50)
go
Alter database WSS_SESProposal_Content set Recovery full
GO
Database 3
Alter database WSS_Search_Content set Recovery simple
GO
USE [WSS_Search_Content]
GO
DBCC SHRINKFILE (N'WSS_Search_Content_log',50)
go
Alter database WSS_Search_Content set Recovery full
GO
Find Logical File Name
Declare @LogFileLogicalName sysname
select @LogFileLogicalName=Name from sys.database_files where Type=1
print @LogFileLogicalName
Thursday, February 14, 2013
Deploying SSIS Packages in SQL Server 2008/2012
1) Create the SSIS Package and Execute it.
2) After executing the solution, the deployment utility is created in the default location if the build is completed successfully. Navigate to the (default location) deployment folder, C:\SSIS\Packages\Import\ExcelFile\bin\Deployment in our case and we will find the deployment files i.e. the integration services project deployment file (ExcelFile.ispac).
3) Copy the Deployment file(local machine) to the SQL Server Server (Target Server).
2) After executing the solution, the deployment utility is created in the default location if the build is completed successfully. Navigate to the (default location) deployment folder, C:\SSIS\Packages\Import\ExcelFile\bin\Deployment in our case and we will find the deployment files i.e. the integration services project deployment file (ExcelFile.ispac).
3) Copy the Deployment file(local machine) to the SQL Server Server (Target Server).
Wednesday, December 5, 2012
Integrating Dynamics CRM 2011 Data into SharePoint 2010
- Open the SharePoint site in SharePoint designer 2010.
- Select External Content Types and click External Content Type (ECT).
- Use the following settings on it
Name: CRM Board Entity
Display Name: CRM Board Entity
Click on link next to External System.
Subscribe to:
Posts (Atom)

