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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -