Alerting the DBA on New DB Creation and the same should be backed up.
Hello,I am not good at t-sql and hence need your suggestions here. I have a requirement like, whenever the new Database got created, the database should get backup in next sec/min. Do we have any ways...
View Articlehow to know which query hampering performance in stored procedure?
hi, i have thousand lines of code how do i know which query is causing slow performancecould any one suggest please?
View ArticleT-SQL: Manual Backup of Multiple Databases
I am looking to change the way I do manual backups of multiple databases on the same instance of SQL Server 2008 R2.Currently I have T-SQL scripts for each database that look like this:BACKUP DATABASE...
View Articletrying to convert SELECT query to Update query with INNER JOINS
Assalam O Alaikum!I've tried to convert this query of mine but failed.I wish to use it for update datasource in data GridView. I'm fetching data with it but converting it to update is not helping...
View ArticleDatabase Mail problem
Hi all,I have searched and tried every solution possible but none of them worked.May be I didn't apply well the steps, and that's why I'm here.My problem is with "Database Mail", when I try to start it...
View ArticleUsing Merge Update and Insert One table to another
Hi, I have a source and destination table. Using merge statement i want to update and insert all data only specific columns from source to destination. For Example Source Table: Destination...
View ArticleWeird behaviour with Variables of a Stored Procedure
Hello All, I'm writing following stored procedure and it is failing with following error"Conversion failed when converting from a character string to uniqueidentifier" What's Happening? I've...
View ArticleLost with conversion of nvarchar to decimal and date
I am totally stuggeling with the the conversion from nvarchar datatype to decimal and date.I extracted data from SAP with SE16 imported the flat file to SQL server. All fields have the datatype...
View ArticleStored Procedure- Multil level employee hierarchy in the same row
I have an employee table where I have employee details which includes the following properties:EmployeeID, EmployeeName, ManagerID, DesignationCode.ManagerID maps to EmployeeID in the Emp table....
View ArticleTable value parameters Question
I would like to use a table valued parameter to create an invoice. It will insert into the invoice header data table the header and then it will insert the invoice detail all with different tables. The...
View Articlewhat is better max() or scope_identity()
I need to retrieve identity value for inserted record in a stored procedure. The value is then used to insert a record in a related table to establish relationship. The stored procedure called from...
View Articlet-sql 2008 r2 use 2 ctes
In existing t-sql 2008 r2 that I need to modify, there is already an existing cte that looks like the following: ;WITH rCust AS ( SELECT [UserSK]...
View Articledatediff in minutes in request_history table
I have a request_history table as follows.How can I get the datediff in minutes for time between when rid 104 was in QA Ready status and then Sign Off...
View Articlehow to count and calculate total percentage for Every product in field?
hi all,i have two tables as follow:i have a inner join as follow :SELECT distinct dbo.Motor_Story.Name, dbo.Goods.kala, dbo.Goods.type, dbo.Goods.id_story FROM dbo.Goods INNER JOIN dbo.Motor_Story ON...
View ArticleScan count VS logical Reads
I have two versions of a query.1. Scan count 136, logical reads 2776907,CPU time = 230848 ms, elapsed time = 55753 ms.2. Scan count 0, logical reads 89225788, CPU time = 437696 ms, elapsed time =...
View ArticleNaming Convention - Sql Objects
Hi, Can you please advice me on Naming Convention of Sql Objects.lets say1.Table,2.Stored Procedure,3.View,4.User Defined Function,4.Trigger etc..Please advice me on this same for please give me one...
View ArticleDDL trigger not capturing previous schema for ALTER SCHEMA TRANSFER
Hi,I have a DDL trigger which captures ALTER SCHEMA TRANSFER queries. The EVENTDATA() shows the following:<EVENT_INSTANCE> <EventType>ALTER_SCHEMA</EventType>...
View Article