473,827 Members | 3,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create Status Table

I have >200 tables and I want to create a table that lists the name of
each table, the number of records, and the number of locations within
the table.

I've created a cursor to do this but it doesn't like it. I get the
following error.

Invalid column name '<tablename>'.

Here's my script

DECLARE @tbl varchar(100)
DECLARE @sql varchar(1000)
-- Insert statements for procedure here
declare c_table cursor for
select table_name from INFORMATION_SCH EMA.TABLES where table_type =
'base table' order by table_name

open c_table
fetch next from c_table into @tbl

while (@@fetch_status = 0)
begin

set @SQL = 'INSERT INTO [zzTable_Status]
SELECT ('+ @tbl +') as tblname, count(distinct station__no),
count(station__ no)
FROM [bronze_views].'+@tbl+''

exec (@SQL)

Print @tbl + ' Updated'

fetch next from c_table into @tbl
end
close c_table
deallocate c_table

Any help is appreciated...

May 16 '06
13 3045
SQL
also take out the dot here
The code works but the dot shouldn't be there anyway
instead of this
FROM .'+@tbl+''
use this
FROM '+@tbl+''

Denis the SQL Menace
http://sqlservercode.blogspot.com/

May 16 '06 #11

"db55" <ch****@gmail.c om> wrote in message
news:11******** **************@ v46g2000cwv.goo glegroups.com.. .
I have >200 tables and I want to create a table that lists the name of
each table, the number of records, and the number of locations within
the table.


Out of curiousity, WHY?

May 17 '06 #12
Hi db55,

I think this will help you

Create Table TableNameRow
(
TableName varchar(100) Not Null,
recs int
)
Go
Exec sp_msforeachtab le 'Insert into TableNameRow Select ''?'',count(1)
from ?'
Go
Select * from TableNameRow

With Warm regards
Jatinder Singh
http://jatindersingh.blogspot.com

May 17 '06 #13
I want to track the status of each table. I'm importing millions of
records into these tables and I want to track them. I also create
reports for my mgmt with the data pulls.

I always make sure I ask that question so I'm not wasting my time.

Thanks for asking...

May 24 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6583
by: dev | last post by:
how create a temp table as a copy of a existing table and then update1 field and insert the hole temp table back in the existing table? please any help? if i have 10 fields in 1 record and about 100 records and a field.status=1 in a existing_table and i want to create a temp_table with all the recordse and values of the existing_table and then update the field.status to 2 and insert in 1 query the temp_table in the existing_table
0
1162
by: Morten Gulbrandsen | last post by:
USE company; DROP TABLE IF EXISTS EMPLOYEE; CREATE TABLE EMPLOYEE ( # PK SSN CHAR(9) NOT NULL, # FK SUPERSSN CHAR(9), DNO INT NOT NULL DEFAULT 1, CONSTRAINT EMPPK
0
3778
by: HumanJHawkins | last post by:
Hi, I am trying to create an index from a stored procedure. The stored procedure runs without error, but when I try to use "CONTAINS" or "FREETEXT" on the table, it tells me that I can't because the table is not indexed. At the point of this code, a table called 'SearchCompareBase' is already created and full of data. The syntax I am using to index that table follows. Can anyone help me get it working:
2
5039
by: Rich Lussier | last post by:
access 2000 newbie here - I need to create a new table (make-table query) selecting from the following fields in a table: netname | IP_address | port_number | status | connection The records can contain duplicate information since the connection and port number fields will be different. Netname and IP_address can be duplicated - and I want to create a new table
6
2488
by: skgolden | last post by:
My husband and I own a small temporary labor company and deal with 4 major clients (A,B,C & D), each of which has about 2 dozen units in our tristate area that we deal with (ie, Company A, units a,b,c,d,e etc). We send temps possessing various skills (cashier, cook, hostess, etc) to the individual units as needed. What I'm trying to do is create a schedule we can use each day, for example: Monday, June 1, 2004 Company A, unit e Alice...
1
6291
by: md7546 | last post by:
Hi, first time posting to this group, but I have followed advice and examples for several months, so thank you. I work for a small telecommunications company. I have a simple Orders database that has an Orders table to track a sales order, using OrdersID as the PK. I have a related one-to-many table called OrderDetails, with the OrdersID as a FK, which shows all the products sold with that order. Then I have an Update table, in a...
2
3135
by: Shrutisinha | last post by:
Hi Guys Really need your help I donno what I am doing wrong in here Want to create a table with another existing table Here is the syntax I am using create table pctemp1 As (SELECT distinct a.Promo,b.Ban,b., b.,b. FROM PC_FUSION_070424 a
4
111189
by: Shrutisinha | last post by:
Hi Guys Really need your help I donno what I am doing wrong in here Want to create a table with another existing table Here is the syntax I am using create table pctemp1 As (SELECT distinct a.Promo,b.Ban,b., b.,b. FROM PC_FUSION_070424 a
1
1219
by: jiaudheen | last post by:
i have admin login form and status updation form. the admin get logged in and the update the status of the the customer smart card. the status page have a gridview which is bound to sqldatabase table which has fields.. 1. Application no. 2. apllication date. 3. customer name 4. status. ( in status column of the grid we have dropdowns holding 3 values. pending, produced, delivered). the status can be updated from the grid. now the...
3
7201
by: DeanL | last post by:
Hi guys, Does anyone know of a way to create multiple tables using information stored in one table? I have a table with 4 columns (TableName, ColumnName, DataType, DataSize) and wanted to know if there is a way to use the information in this table to create the many tables that are listed in the source table instead of creating each table individually? Many thanks for any help you can offer.
0
9773
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9632
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10467
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10507
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9294
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7731
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6936
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5612
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5769
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.