x

Add concatenated column to temp table when I don't have ADD permission

I do not have ADD or DELETE or ALTER permission in my instance of SQL Server. I have a temp table in which I want to add a column to.

This new column is a concatenation of other columns and I want to write it to another temp table.

Right now, when I employ the CONCAT code below, the output is just that one column. I want to have the CONCAT column along with all the other columns in my original temp table (#df_ERA4_b).

 SELECT CONCAT(A, OP, F, SUB, AIR, D, REQ, P) as CONCAT_COL INTO #df_ERA4_c  FROM #df_ERA4_b

How can I achieve this?

more ▼

asked Nov 13 at 09:08 PM in Default

avatar image

pinenuts000
1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

You are almost there. The reason you end up with only one column in your #df_ERA4_c destination table is because you only include but one column named CONCAT_COL in your select list. If you need all columns followed by CONCAT_COL then all you need to do is add all columns to the list:

 select 
     *, concat(A, OP, F, SUB, AIR, D, REQ, P) as CONCAT_COL into #df_ERA4_c  
     from #df_ERA4_b

This script should produce desired result.

Hope this helps.

Oleg

more ▼

answered Nov 14 at 01:50 PM

avatar image

Oleg
18.9k 3 7 28

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x242

asked: Nov 13 at 09:08 PM

Seen: 10 times

Last Updated: Nov 14 at 01:50 PM

Copyright 2017 Redgate Software. Privacy Policy