Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
28 views

I have the following piece of script that loops through multiple identical databases (55 of them). I am trying to get the database name as a column, but it keeps giving me the master db_name as this ...
Wynand Cilliers's user avatar
0 votes
1 answer
50 views

I want to find the reference of particular table in all the databases of the particular server. Example : My query window is opened for DB1 database and executed the query as: exec sp_depends 'dbo....
jayesh kshirsagar's user avatar
0 votes
1 answer
635 views

I'm setting up a new way to create and delete backups in our internal environments. The space on the servers is a big issue so i really have to find a way to do a backup and delete the older one for ...
InfiniteLoop's user avatar
0 votes
1 answer
533 views

I need to extract data from different DBs into a single table. These DBs are all in the same Server and Instance and they have the same structure. One of the columns will be DB Name, the others come ...
ᗩИᎠЯƎᗩ's user avatar
0 votes
2 answers
2k views

I am having issues getting information to insert into the @TBL2 Table. what am i doing wrong? DECLARE @command varchar(1000) DECLARE @SQLStatment varchar(1000) DECLARE @TBL2 table ( ...
Max's user avatar
  • 17
0 votes
1 answer
796 views

I want to run a SELECT statement on only some specific databases. The list of databases is returned by this query: DECLARE @OneWeekAgo DATETIME SELECT @OneWeekAgo = DATEADD(week,-1,GETDATE()) select ...
user3566591's user avatar
1 vote
4 answers
384 views

I am running the following code to extract all relevant rows from all tables that have a particular column. The outer IF is supposed to check if the column exists on the table for that iteration. If ...
Jonathon Anderson's user avatar
-1 votes
1 answer
1k views

Anyone able to convert the following SQL query using sp_MSforeachdb? I am using SQL Server 2005 SP4. Thanks! DECLARE @tmpResults TABLE (Owner sysname, Object sysname, Grantee sysname, Grantor sysname,...
gcormier9's user avatar
0 votes
3 answers
1k views

Can someone tell me why the following code only returns one row from the DataSet (for the master db) instead of one for each database on the server? $SQLConn = New-Object System.data.SqlClient....
user2089287's user avatar
0 votes
1 answer
4k views

I have created a SQL Server 2008 Agent job that runs against all databases on the server. I am using the undocumented MS procedure, sp_MSforEachDB. I am specifying only certain databases to be ...
lonslo's user avatar
  • 3
2 votes
1 answer
275 views

I'm trying to create a SQL Server script that applies some operations to all the tables in all the databases. I need to rename some tables if some conditions are respected, truncate the tables ...
Katie's user avatar
  • 659
0 votes
2 answers
4k views

How Can i iterate thru the all my DB's and get a row count for each employee table? Each client is has there own DB, need to find the total employees in each DB. Been trying to figure out how to use ...
Yogurt The Wise's user avatar
3 votes
1 answer
697 views

I'm working to enhance my understanding of some system sprocs and I'm very confused by this script I was working on. To exercise my understanding of sp_MSForEachDB I decided to write a script that ...
Jaxidian's user avatar
  • 13.6k
1 vote
1 answer
1k views

I am trying to use the following stored procedure to obtain databases from a server. However, I just want the databases created from a month ago. What do I have to do to make this work? Here is ...
Jeff's user avatar
  • 882
0 votes
2 answers
7k views

I'm working with a lot of databases that are the same so I am using the sp_MSforeachdb procedure so that I can retrieve information from a table. The problem I have encountered is that there are ...
Paul Talbot's user avatar
  • 1,613
1 vote
4 answers
7k views

Where I'm at we have a software package running on a mainframe system. The mainframe makes a nightly dump into sql server, such that each of our clients has it's own database in the server. There ...
Joel Coehoorn's user avatar