View Complete Post
There might be an easier way to perform it, if so, please advise. I am looking for a scriptable solution (preferably TSQL).
I want to code a tsql procedure to restore a database from a backup file (.bak). The procedure must allow to restore a backup from a database to a different database.
When performing it through the SSMS interface, I see all the files in the .bak file. From there, I can associate the files in the backup to the appropriate files in my destination database. when generating TSQL, this translates to MOVE
statements for the files.
Can I translate the whole process in TSQL? In order to know how to map my files, I must first gather the information on which files are present in my bak file. Can one read the definition of the files contained in a backup file before performing
the restore. Preferably using TSQL?
Is there is any way to get current logged in user and password using a TSQL?
Sajid P K
I need to write a automatic query. Please see below for example.
Date: 4/4/2010 (Monday), 4/5/2010 (Tuesday), 4/6/2010 (Wednesday)
So from every Monday - Sunday (End of the week) the result = Week of October 4th 2010
Date Day Wanted Result
4/4/2010 Mon Week of Oct 4 2010
4/5/2010 Tue Week of Oct 4 2010
4/6/2010 Wed Week of Oct 4 2010
4/7/2010 Thur Week of Oct 4 2010
4/8/2010 Fri Week of Oct 4 2010
4/9/2010 Sat Week of Oct 4 2010
4/10/2010 Sun Week of Oct 4 2010
4/11/2010 Mon Week of Oct 11 2010
Thanks loadzzz in advancee
Could please tell me best way to replace first occurrence of word in Tsql ?
SET @SQL = 'select 1 as X, 1 as Y, 3 as z from
Select * from Table1
I need to replace first “select” to another word.
i have a query that will select employees from a database and return the total number of credits that they have, by using a sum a.credits where is completed =1 for total awarded credits... What i need is to have the query also return another field that is
total credits.. where iscompleted=1 and 0 and then adds the credits up with a sum.... any ideas..?
thanks in advance
select x.EmployeeId, SUM(a.Credits) as TotalAwardedCredits
from XREFEmployeesInvitations x
inner join Activities a on a.Id = x.ActivityId
inner join Employees e on e.Id = x.EmployeeId
where IsCompleted=1 and IsSpouse=0
and e.Id in
(select distinct EmployeeId
where IsCompleted=1 and A