Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add records from one table to another
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01652499
Message ID:
01652506
Views:
46
>>>Merge is bullet-proof command, so you can run it multiple times. INSERT SQL will work as well once, but you can not run it the second time. So, if you're using SQL 2008 and up I suggest to forget about INSERT-SQL and UPDATE commands and always use MERGE command. The syntax will take a bit of time to get familiar with, but you will be better protected using this command.
>>>
>>>BTW, the correct syntax for above INSERT will be:
>>>
>>>insert into Ten_name (ten_pk, user_id, user_pwrd)
>>>select ten_pk, user_id, user_pwrd from Tenant x
>>
>>Thank you. Then, in your syntax the 'x' after Tenant is not really necessary, right?
>
>Right, for single table it is not necessary. It helps with intellisense, though. E.g. if you add x at the end you can type x. and the column name will come up.

I have a follow up question, please. If one of the columns I want to "copy" to the target table has to be parsed, how would I do it? For example. The source table has field USER_NAME and the entry in this field is Last Name, First name. E.g. "Smith, John", "Nosonovsky, Naomi", and so on. I want to parse this field into the two fields of the Target table, FNAME and LNAME. Does SQL have SUBSTR() for that?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform