Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
memo:sql [13/04/2022 10:41] – [MSSQL : lier un utilisateur à une connexion] Arnaud Jacqueminmemo:sql [03/11/2025 17:35] (Version actuelle) – [MSSQL : trouver les verrous sur une table] Arnaud Jacquemin
Ligne 151: Ligne 151:
  
 ==== Texte -> date ==== ==== Texte -> date ====
 +
 +=== Oracle ===
  
 Fonction TO_DATE Fonction TO_DATE
Ligne 175: Ligne 177:
 </code> </code>
 Doc : https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017#g-using-cast-and-convert-with-datetime-data Doc : https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017#g-using-cast-and-convert-with-datetime-data
 +
 +
 +=== MySQL ===
 +
 +<code sql>
 +SELECT STR_TO_DATE("2022/03/25", "%Y/%m/%d"
 +</code>
 +
 +Doc : [[https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_str-to-date| STR_TO_DATE(str,format)]] et [[https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format|formats]]
  
  
Ligne 398: Ligne 409:
 Doc : [[http://www.postgresql.org/docs/9.0/static/sql-createtableas.html|PostgreSQL]] Doc : [[http://www.postgresql.org/docs/9.0/static/sql-createtableas.html|PostgreSQL]]
  
 +Testé avec M$ SQL Server :
  
 +<code sql>
 +SELECT *
 +INTO destination
 +FROM source;
 +</code>
 +
 +Doc : https://learn.microsoft.com/en-us/sql/t-sql/queries/select-into-clause-transact-sql
 ====== ALTER TABLE ====== ====== ALTER TABLE ======
  
Ligne 417: Ligne 436:
 GO GO
 </code> </code>
 +
 +====== MSSQL : copier des tables d'un schéma à un autre ======
 +
 +> Use the Generate Scripts Wizard in SSMS for generating the script for constraints and indexes.
 +>
 +>Follow these steps:
 +>
 +>1. Open SSMS
 +>2. Expand databases and select the database->tasks->generate scripts to launch the GSW
 +>3. click next and set "Script Check Constraints" to true, "Script Indexes " to true, "ScriptDependencies" to true and set whatever is needed.
 +>4. Select the tables for which the script is needed
 +>5. Click next ->next->finish
 +>
 +>This generates the script for table with indexes, constraints etc.
 +>
 +>More information: http://msdn.microsoft.com/en-us/library/ms178078.aspx
 +
 +Source : https://social.msdn.microsoft.com/Forums/en-US/17a16dc4-dcf1-4de8-baba-6949c55a4c5d/copy-constraints-and-indexes-from-one-database-to-another?forum=transactsql
 +
 +====== MSSQL : trouver les verrous sur une table ======
 +
 +<code sql>
 +SELECT 
 + object_name(object_id) AS objet_bloque, 
 +    lock.resource_type,
 +    db.name AS db_name,
 +    lock.resource_associated_entity_id,
 +    lock.request_mode,
 +    lock.request_session_id,
 +    task.blocking_session_id,
 +    task.*
 +FROM sys.dm_tran_locks lock
 +INNER JOIN sys.partitions p ON p.hobt_id= lock.resource_associated_entity_id
 +INNER JOIN sys.databases db ON db.database_id = lock.resource_database_id
 +LEFT JOIN sys.dm_os_waiting_tasks as task
 +    ON lock.lock_owner_address = task.resource_address
 +LEFT JOIN sys.dm_os_tasks AS STasks
 +    ON STasks.task_address = task.waiting_task_address
 +WHERE resource_database_id = 20 AND object_name(object_id) = 'NOM_DE_LA_TABLE'
 +</code>
 +
  
 ====== Documentations ====== ====== Documentations ======
  • memo/sql.1649839273.txt.gz
  • Dernière modification : il y a 4 ans
  • de Arnaud Jacquemin