Skip to content
Advertisement

Tag: sql

SQL Server: select records, not linked to another table

I have a table: and a linked table: Relationship between these 2 tables: I want to select all records from CollectionSiteAddress, which are not linked to CollectionSite (neither AddressId nor RemittanceId). Which request should I use? I tried: but it selects all records from CollectionSiteAddress Answer You are missing this WHERE clause: because you want all the unmatched rows of

Naming a default constraint

I’m trying to create a default constraint here, but the system is generating a weird name for it. If I want to name it df_MY_TABLE_GUID or something, how could I specify that name be used? Answer Just specify the constraint name with the full syntax, like the UNIQUE in your example: As a matter of routine, I always prefer and

Summarize aggregations into friendly text

This is my table in SQL Server : and I want this output in SQL Server (return this Text with Query not function): Does anyone know how I can do this? Answer Modern Versions If on SQL Server 2017 or better, you can also do it this way (and this prevents you from having to know in advance and hard-code

Advertisement