Trying to copy part of some text out of 1 column in a table and insert it into a 2nd column.
I managed to get the following query to return the part thatI need which worked ok:
SQL
SELECTImportAll,left(ImportAll,charindex(',',ImportAll)-2)ASLeftStringFROMDocumentInventory.CompanyPri;
I used some Google searches for this and although it works does anyone know what the -2 does. When i change that number nothing changes in the output and although i understand the rest of the code I really don't know what that bit does. Just that it is needed.
So then I tried to get it to insert into the next column called DocumentSource. Insert Into didn't seem to work so I tried to store it in a variable and add it that way:
SQL
DECLARE@vDSnvarchar(100)SET@vDS=(SELECTImportAll,left(ImportAll,charindex(',',ImportAll)-2)ASLeftString...