Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,I have a table with three columns.Table1:col1 nvarchar(100)col2 intcol3 intcol1 has other table namescol2 has count of records in those tablescol3 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 ' + @col1exec sp_executesql @sql, N'@col2 int output', @col2 OUTPUT. . .insert into table1 (col1, col2, col3)select @col1, @col2, @col3