This was a strange problem! A user tried to activate the "SharePoint Server Publishing Infrastructure" feature and received an error saying "A duplicate content type named "Report" was found." In addition to this problem there were a couple of features that were enabled for testing that I was unable to disable.
The problem was fixed by disabling the two features circled below:
Once these two feature were deactivated the "SharePoint Server Publishing Infrastructure" feature could be activated.
No words wasted! Getting to the point about the work I do, the problems I deal with, and some links to posts about where I work.
Translate
Wednesday, April 24, 2013
Friday, April 12, 2013
SQL - List Size Information for all Tables
I needed to find how many records I had in the "look-up" tables for my web application. All of my look-up tables start with "lu".
This is the query I used:
Thanks to stackoverflow.
This is the query I used:
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME like 'lu%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, p.Rows
ORDER BY
p.rows
Thanks to stackoverflow.
Tuesday, April 9, 2013
SQL - Search All Tables and Fields for a Value
I needed to be able to search a database to find a value in any table and field. The first listing was too slow on my large database.
From http://vyaskn.tripod.com:
This one runs faster but lacks the detail of the first listing
From experts-exchange:
From http://vyaskn.tripod.com:
CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN
-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.
-- Purpose: To search all columns of all tables for a given search string
-- Written by: Narayana Vyas Kondreddi
-- Site: http://vyaskn.tripod.com
-- Tested on: SQL Server 7.0 and SQL Server 2000
-- Date modified: 28th July 2002 22:50 GMT
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
SET NOCOUNT ON
DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)
WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)
IF @ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)
END
END
END
SELECT ColumnName, ColumnValue FROM #Results
END
This one runs faster but lacks the detail of the first listing
From experts-exchange:
Declare @TN as varchar(200), @CN as varchar(200), @myValue varchar(30), @SQL as nvarchar(1000)
, @SN as varchar(200), @Exact_Match bit
Create Table #myTable (Table_Name varchar(200), Column_Name varchar(200), Number_Of_Rows int)
-- Replace @myValue with the value you're searching for in the database
Set @myValue = 'Value to Search'
-- 0 for LIKE match, 1 for exact match
Set @Exact_Match = 1
Declare myCursor Cursor For
Select T.Table_Name, C.Column_Name, T.Table_Schema
From INFORMATION_SCHEMA.TABLES T Inner Join INFORMATION_SCHEMA.COLUMNS C
On T.Table_Schema = C.Table_Schema And T.Table_Name = C.Table_Name
Where T.Table_Name <> 'dtproperties' And Table_Type = 'Base Table'
And C.Data_Type In ('varchar','char','nvarchar','nchar','sql_variant')
--And C.Data_Type In ('text','ntext')
--And C.Data_Type In ('tinyint','int','bigint','numeric','decimal','money','float','smallint','real','smallmoney')
--And C.Data_Type In ('datetime','dmalldatetime')
-- Fields not searched: image, uniqueidentifier, bit, varbinary, binary, timestamp
Open myCursor
Fetch Next From myCursor Into @TN, @CN, @SN
While @@Fetch_Status <> -1
Begin
If @Exact_Match = 0
Set @SQL = N'Insert Into #myTable Select ''' + @SN + '.' + @TN + ''', ''' + @CN + ''', Count(*) From [' + @SN + '].[' + @TN + '] Where [' + @CN + '] Like ''%' + @myValue + '%'''
Else
Set @SQL = N'Insert Into #myTable Select ''' + @SN + '.' + @TN + ''', ''' + @CN + ''', Count(*) From [' + @SN + '].[' + @TN + '] Where [' + @CN + '] = ''' + @myValue + ''''
--Print @SQL
Exec sp_executesql @SQL
Fetch Next From myCursor Into @TN, @CN, @SN
End
Close myCursor
Deallocate myCursor
Select * From #myTable Where Number_Of_Rows > 0 Order By Table_Name
Drop Table #myTable
SQL - List All Triggers
I'm working on a large database with over 2400 tables and I wanted to know what all of the triggers are and where they're located.
This is the query I ran to get that information:
This is the query I ran to get that information:
SELECT
ServerName = @@servername,
DatabaseName = db_name(),
SchemaName = t.TABLE_SCHEMA,
TableName = object_name( o.parent_obj ),
TriggerName = o.name,
Definition = c.text
FROM sysobjects o
JOIN syscomments c ON o.id = c.id
JOIN INFORMATION_SCHEMA.TABLES t ON object_name( o.parent_obj ) = t.TABLE_NAME
WHERE o.type = 'TR'
ORDER BY SchemaName, TableName, TriggerName
Thursday, April 4, 2013
SQL - List Database Tables, Fields, and Other Information
There are a few SQL scripts around for listing table information. This is the one that I use. Just replace "YourDatabaseName" with the name of the database.
USE [YourDatabaseName];
SELECT OBJECT_SCHEMA_NAME(T.[object_id],DB_ID()) AS [Schema],
T.[name] AS [table_name], AC.[name] AS [column_name],
TY.[name] AS system_data_type, AC.[max_length],
AC.[precision], AC.[scale], AC.[is_nullable], AC.[is_ansi_padded]
FROM sys.[tables] AS T
INNER JOIN sys.[all_columns] AC ON T.[object_id] = AC.[object_id]
INNER JOIN sys.[types] TY ON AC.[system_type_id] = TY.[system_type_id] AND AC.[user_type_id] = TY.[user_type_id]
WHERE T.[is_ms_shipped] = 0
ORDER BY T.[name], AC.[column_id]
SQL - Listing All of the Records From Multiple Tables
I was asked to provide a list of all of the records from some look up tables that I use for my project. There are almost 60 look up tables! I spent some time thinking about how to do this in the SQL database. Then I realized, the easy answer is to connect MS Access to the SQL server and then select the tables I need and import them into Access.
Subscribe to:
Posts (Atom)