Morning,
I know I am close BUT I still can't get this code snippette to return the date of last sunday (as in 1/9/2011 - format of date does not matter).
Here is what I have so far (borrowed from a web page):
DECLARE @LastSundayNight DateTime
SET @LastSundayNight = GetDate()
SELECT CASE...
I am trying to update a record set with the last restore date that is captured with a TOP clause in the code.
Here is the code (that does not work):
UPDATE MyTable
SET MyDate =
( SELECT TOP 1 RESTORE_DATE
FROM MSDB.dbo.RESTOREHISTORY WITH (nolock)
JOIN MyTable
ON...
OK .. brain dead for a Friday - lol
So I have a server where I am "trying" to call a remote stored proc to load a local table.
Somthing like ...
INSERT INTO Admin.dbo.MyTable (
Col1,
Col2 )
EXEC MyRemoteDB.dbo.MySP
Now Admin.dbo.MyTable is the local table and MyRemoteDB.dbo.MySP...
I have an instance of 08R2 running on my box with an instance of 05SP3.
Running the query in the 05 instance returns the result sets from the remote server just fine.
When I run it from the R2 instance it failes with the followig error:
OLE DB provider "SQLNCLI10" for linked server "(null)"...
Just the reverse for me ... works in 05 (some setting I hit quite a while back) but not in 08R2.
Trying to hunt down where its set at.
Thought it was a part of IntelliSense.
Thanks
J. Kusch
I know I have toggled it on in the past but where do you set Mgt Studio to show you how your commands line up?
In other words, If I use an IF\ELSE statement I want to be able to highlight the IF and it shows me the corresponding ELSE further down in the code.
Thanks!
Thanks
J. Kusch
OK ... figured it out ...
INSERT INTO TableB
(DBName, Field1, Field2, Field3)
SELECT [Name],
'',
0,
0
FROM Master.dbo.SysDatabases
WHERE NOT EXISTS (SELECT *
FROM TableB
WHERE TableB.DBName = Master.dbo.SysDatabases.[Name])
AND Status = 536
Thanks
J. Kusch
Ahhh ... one issue ... using SysDatabases (system table) so we cannot add that trigger.
Looking for code that would look something like:
If database(s) in sysdatabases set to offline then add database NAME from SysDatabases to TableB IF it does not already exist.
If it exists already in...
TableA has database name column and active\inactive flag
TableB has database name
When we inactivate database(s) in TableA we want code later on to insert the newly deactivated database(s) name(s) into TableB.
I know code with use an IF NOT EXIST on the TableB insertion code, just not able to...
I have a table (TableA) that needs to have a date field updated with a MAX(Date) from another table (TableC).
To add to this ... We need to join to a TableB to get an ID to have it hook up right.
So TableA looks like:
DBName varchar(100),
CreateDate DateTime
TableB looks like:
DBName...
Afternoon,
I need to figure out the syntax to create a stored procedure in every one of our database (all 1200+) which is part of a stored procedure execution logging process.
I have been trying to get MSForEachDB to work.
Any ideas on how to accomplish this task?
Thanks
Thanks
J. Kusch
in Enterprise Manager, drill down on the database and choose detach.
Once detached, move the physical file to its needed share.
Once in place, r-click on the database tree label in EM and choose attach.
Point the location of the TLog (which should be showing as missing) to the new location...
Say I have a string of:
R:\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\model.mdf
and I want to know the position of the last \ (which would be position 43).
Thanks!
Thanks
J. Kusch
That is not permitted ... you can have multiple "instance" of SQL server but it has to be on the same physical machine.
Having a backup and a production server would require 2 licenses.
Thanks
J. Kusch
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.