TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sathya Sambath
NA
284
117.5k
how to write the delete and reseed for stored procedure?
May 3 2018 5:50 AM
hi,
I have one database for eg 300 table ,i have delete specify the 200 table data only and then reseed identity the delete table .
but error withshown .
DECLARE
@DeleteTableStatement nvarchar(
max
)
DECLARE
C2
CURSOR
READ_ONLY
FOR
SELECT
'Delete From [dbo].['
+ TABLE_NAME +
']'
from
INFORMATION_SCHEMA.TABLES
WHERE
TABLE_SCHEMA =
'dbo'
and
TABLE_NAME
NOT
IN
(
'xxx'
,
'aaa'
,
'bbb'
,
etc
)
-- Change your schema appropriately.
OPEN
C2
FETCH
NEXT
FROM
C2
INTO
@DeleteTableStatement
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT
'Executing '
+ @DeleteTableStatement
execute
sp_executesql @DeleteTableStatement
DBCC CHECKIDENT (@DeleteTableStatement, RESEED,1);
FETCH
NEXT
FROM
C2
INTO
@DeleteTableStatement
END
CLOSE
C2
DEALLOCATE
C2
Reply
Answers (
3
)
Pivot more than one columns in SQL
Sql script to update urls