database - Truncate tables only with on schema -
i'm looking way truncate tables on 1 schema only. i'm getting list of tables on schema:
*select name, object_id sys.objects schema_id = (select schema_id('seg'))*
but i'm struggling find way truncate result set.
thanks points!
refer link or try script
declare @sql nvarchar(max) = '' select @sql = ( select 'truncate table [' + s.name + '].[' + o.name + ']' + char(13) sys.objects o (nowait) join sys.schemas s (nowait) on o.[schema_id] = s.[schema_id] o.[type] = 'u' , s.name = 'dbo' xml path(''), type).value('.', 'nvarchar(max)') print @sql --exec sys.sp_executesql @sql
Comments
Post a Comment