posts - 5 , comments - 1 , trackbacks - 0

My Links

News

Archives

Post Categories

IIS

SQL

Reset Identity column in SQL table
To reset Identity from 1Below would reset identity column of SQL table and start Identity column value from 1DBCC CHECKIDENT (TABLE_NAME, reseed, 0)To reset Identity from the specified value Say, If records are already deleted (from 31 to the end record ) and if user would like to create record from 31 then below will workDBCC CHECKIDENT (TABLE_NAME, reseed, 30)– Karthick Raju ......

Posted On Friday, November 4, 2016 6:44 AM | Comments (1) | Filed Under [ SQL SQL Server ]

How to execute Dynamic SQL query
Below SQL script would help to run simple dynamic queryDECLARE @SQLQuery NVARCHAR(500) — To see max length for NVARCHARSET @SQLQuery = N’SELECT * FROM TABLE_NAME’ — To understand why N’ in this lineEXEC(@SQLQuery)Ensure you execute dynamically framed query like EXEC (@SQLQuery) not like EXEC @SQLQuery. If you execute like later then you would get below errorMsg 2812, Level 16, State 62, Line 3Could not find stored procedure ‘SELECT * FROM TABLE_NAME’.-Karthick Raju ......

Posted On Friday, November 4, 2016 6:43 AM | Comments (0) | Filed Under [ SQL SQL Server Dynamic Query ]

Powered by: