Archivi categoria: SQL

MySQL Delete rows subquery You can’t specify target table ‘XXX’ for update in FROM clause

Today my colleague and I have received a gift from MySQL. Our goal was to delete some rows obtaining them using a subquery. Here is the query: And here the response of MySQL You can’t specify target table ‘ps_pack’ for … Continua a leggere

Pubblicato in SQL | Contrassegnato , , | Lascia un commento

Entity Framework left outer join

Many times I talked about Entity Framework join by linq. Today I show how to do LEFT OUTER JOIN or LEFT JOIN. Notice the end of line “join sve”, you’ll notice “into sveList” Then I call DefaultIfEmpty on this var … Continua a leggere

Pubblicato in c#, Entity Framework, SQL | Contrassegnato , , , | Lascia un commento

Entity Framework Many to Many join

If you use Entity Framework 6 (EF) design first to create the domain classes if you have a relationship many to many without any extra field inside the join table, EF will avoid to create the join table model. On … Continua a leggere

Pubblicato in c#, Entity Framework, SQL | Contrassegnato , , , , | Lascia un commento

Recursive SQL server Query

This query permit to get all child recursive, starting from a unique parent

Pubblicato in SQL | Contrassegnato , , | Lascia un commento

Work on SQL Compact Edition 4.0

All of us we have installed at least SQL express and when we work with SQL CE nothing else is necessary to be installaed. But when the project will be published in a computer without SQL installed we will get … Continua a leggere

Pubblicato in .Net, Asp.Net, SQL | Contrassegnato , , , , , | Lascia un commento

TSQL get records of last week

Today I’ve received this request: realyze a stored proc that return all records from monday of the previus week to today. So If we run this stored proc on monday we will get the last 7 days but if we … Continua a leggere

Pubblicato in SQL | Contrassegnato , , | Lascia un commento

SQL Obtain Date only from DateTime

Another little post: To obtain only the date from the DateTime this is the simpliest method I foud: or

Pubblicato in SQL | Contrassegnato , , | Lascia un commento