Import and Export Wizard with Identity Column
I want to move data from one DB to another, while keeping the identity column values in the old DB. When I run the wizard I get a validation error "Failure inserting into the read-only column "UID". Where UID is an identity column on that table. How can I override the identity functionality in order to be able to import the data?
Answer : By Enable identity insert. There's a check box when you click the Edit Mappings.
SQL Query – List Indexes
—- SQL Query – List Indexes
EXEC sp_helpindex 'tblgroups'
or
declare @tblName varchar(50); set @tblName = 'tbltransaction'; SELECT o.name as TableName, i.name AS IndexName FROM sysobjects o, sysindexes i WHERE (o.id = i.id and o.name = @tblName) AND (i.status = 18450 OR i.status = 2097152)
SQL Query – List Columns of table MS Database
---- SQL Query - List Columns of table MS Database exec sp_columns tblMobileNumbers
SQL Query – List the Fields in the Tables
---- SQL Query - List the Fields in the Tables SELECT [name] AS [Column name] FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE type = 'U' AND [NAME] = 'tblAdmin')
SQL Query – List the Tables in the Database
---- List the Tables in the Database
Select * from sysobjects where xtype in ('u', 's') order by name
SQL Script-COUNT from multiple tables
There are many ways to aproach this (if the tables are not related):
SELECT (SELECT COUNT(DISTINCT id) FROM member) AS members, (SELECT COUNT(DISTINCT id) FROM thread) AS threads, (SELECT COUNT(DISTINCT id) FROM post) AS posts
another way is to write down a Stored Procedure and asign every count to a variable. Then, return:
SELECT @count1, @count2, @count3
If the tables are related a succesive call to a left join would do the trick!

