Hi All,
I am trying to join several tables in MS SQL Server- the problem is that the GUID in one of the tables does not have the dashes. In MS Access, I had created a subquery (query_Table2), added a new column in the query_Table2 using expressions to select the first 7 numbers with the dashes). Then created the join with Table1 <-> query_Table2.
I am New to SQL and MS Sql Server, did some read up on Views, derived tables, etc...kind of confusing. May I know how should I go about doing it in my Sql Server?
I would create a computed column - persisted and indexed, converting the column to the appropriate data type. You would then just join to that computed column.
I don't see a GUID in any column. a GUID has 36 positions and looks like
'BDEA20BE-7D5E-4918-BD43-12FDA4537705'. So I think the field type is a varchar or nvarchar. These do generally don't make good Primary Keys. In this case I would create a new int field for the PK value, create a new column in Table 2 for the foreign key field and run an update query to set the correct values in the FK field. After that the joining would be easy.