Last post Sep 24, 2020 08:03 AM by PaulTheSmith
Sep 24, 2020 12:04 AM|robby32|LINK
I have Select * from mytable join mytable1 on mytable.NAME = mytable1.NAME
I want to change it to
Select * from (GUID) as mytable join (GUID as mytable1 on mytable.NAME = mytable1.NAME
that is put a guid but keep the name of mytable , but it seems it replaces all the mytable if i do a search ?
Sep 24, 2020 02:12 AM|Sean Fang|LINK
Could you please rephrase your problem?
Sorry that I am not sure what your purpose is. Do you want to involve GUID in your table?
If you directly use the modified sql query, obviously you will get an error message =>
Invalid object name 'GUID'.
Select * from GUID as mytable join GUID as mytable1 on mytable.NAME = mytable1.NAME
The correct way to use GUID in SQL server is to use NEWID() function
which will generate a value of type "uniqueidentifier".
Only if you specify the problem would we be able to target the problem and provide you with solutions.
Thank you for understanding.
Sep 24, 2020 03:37 AM|robby32|LINK
I have a query
Select * from mytable join mytable1 on mytable.NAME = mytable1.NAME
Select * from NewId() as mytable join (NewId() as mytable1 on mytable.NAME = mytable1.NAME
so only change the first mytable value and not the others but not the others
Sep 24, 2020 08:03 AM|PaulTheSmith|LINK
The 'as' keyword gives something a different name. So,
NewId() as mytable
means that you have a table whose name is a new GUID and you want to call it mytable. This make no sense at all.
Show us some real tables and some real data and tell us what result you are trying to achieve