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 2005 Forums
 Transact-SQL (2005)
 Select RowCount of table in dynamic Query

Author  Topic 

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-10-02 : 02:52:32
Hello All,

I am trying to generate one script to
insert the data from one database to another database
As i dont have permission to script the data.
So I am writing a dynamic query
to get the insert script for all the tables.
Here is the query -

SELECT 'INSERT INTO '+ name + ' --' + CHAR(13) + 'SELECT * FROM [10.1.4.118].itspatchdb.dbo.' + name FROM sys.tables

this will generate Script like below

INSERT INTO PTH_PatchOthersInstalled --
SELECT * FROM [10.1.4.118].itspatchdb.dbo.PTH_PatchOthersInstalled

I want to get the count of table just next to "--"

Can anyone help me out.



Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
   

- Advertisement -