Posts tagged Tables

List of primary key fields within a database

0
The query below lists the Table Name, Column Name, and Column ID for all Primary Key columns within a database SELECT  t.name AS TableName, c.name AS ColumnName, c.colid AS ColumnID FROM      sysindexes i   INNER JOIN sysobjects t       ON i.id = t.id   INNER JOIN sysindexkeys k     ON i.indid = [...]

List of table columns, with data types

2
The Transact-SQL query below, returns the table name, column name, data type, and maximum length. This is useful when producing database documentation SELECT       schema_name(O.schema_id) + '.' + O.name AS TableName,       C.name AS ColumnName,       T.name AS Type,       C.max_length AS [...]

Apply permissions to all stored procedures or tables

0
DECLARE @SQL varchar(100) DECLARE cObjects CURSOR FAST_FORWARD FOR     SELECT 'GRANT EXECUTE ON ' + name + ' TO [usrTest]' AS SQL     FROM   sysobjects     WHERE  xtype in ('P') /* Or, to Grant select, insert, update, and/or delete permissions, use the following select statement instead of the [...]

MS Access – Remove “dbo_” prefix from imported tables

0
The procedure below, can be used to remove the “dbo_” prefix from all imported tables within a Microsoft Access Database. Public Sub Remove_DBO_Prefix()       Dim obj As AccessObject     Dim dbs As Object       Set dbs = Application.CurrentData       'Search for open AccessObject objects in [...]
Go to Top