Useful SQL Snippets
These are handy little snippets of SQL that see frequent use, particular for non-standard maintenance tasks.
Create A Copy Of A Record
SELECT * INTO TempTable FROM your_table WHERE id ='sourceID';
Update TempTable SET id='targetID';
INSERT INTO your_table SELECT * FROM TempTable;
DROP TABLE TempTable;Reset the Auto Increment.
Delete From credits2018
Where 1=1
DBCC CHECKIDENT ('credits2018', RESEED, 1)Retrieve ID of New Record
try{
queryObj = new Query(
name="qryGet",
datasource="FirstInterview",
sql = "INSERT INTO Cars (make,model) VALUES ('Dodge','Charger'");
returnedObj = queryObj.execute();
} catch (any e) {
}
var newRecordID = returnedObj.getPrefix().generatedkey;Retrieve the Executed SQL Statement
Retrieve Schema For Table
Last updated