Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Can somebody help me with this! Please!!!

Author  Topic 

Nitu
Yak Posting Veteran

81 Posts

Posted - 2006-06-01 : 17:15:07
Hi,

I have a table with three columns.
Table1:
col1 nvarchar(100)
col2 int
col3 int

col1 has other table names
col2 has count of records in those tables
col3 should have the record count of that table in col1 (with a constraint)

Now i need to write a procedure to update this table.

col1 data has to be an input parameter (which is name of a table) to this procedure, col2 is the count of this table, col3 is the count of this table with a inner join to another table with a constraint also.

Can some help me with on how to update this table.

Please i need this urgent.
Really appretitiate if somebody can help me with this.

Thanks a lot in advance,
Nitu

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-01 : 18:06:13
something like this. You can work out col3 yourself.

select @sql = 'select @col2 = count(*) from ' + @col1
exec sp_executesql @sql, N'@col2 int output', @col2 OUTPUT

. . .

insert into table1 (col1, col2, col3)
select @col1, @col2, @col3



KH

Go to Top of Page

Nitu
Yak Posting Veteran

81 Posts

Posted - 2006-06-01 : 18:33:24
Thank you for your reply.
Go to Top of Page
   

- Advertisement -