Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi ,i have 4 tablestable1:PHONE_VERSIONStable2:SBABUILD_versionstable3:TARGETSBUILTVIEWtable4:SBATARGETSBUILTVIEWthe join condition i have isphone_versions.phonebuild=targetsbuiltVIEW.phonebuildand sbabuild_versions.phonebuild=sbatargetsbuilt.phonebuildNow i have to construct a new tableDW_T_Build_Versions BY union of all the 4 tables data long with a new column, "BuildInd" which should display 'target' for the data coming from PHONE_VERSIONS and 'SBA' for the data coming from SBABUILD_VERSIONSPlease find the below link for the excel sheet for the list of coloumns ...http://www.yousendit.com/download/Z01QTGs1Y3kxUUR2Wmc9PQ
yes, i can get all the colomns by joining the tables, but my question is how do i create this into a new table with a new column having the name "target" for data from targetsbuiltview and having "sba" for data from sabtargetsbuiltview, please see the excell sheet attached to my main query...i cannot write create table query by insert these rows and having a specific coloumn with the above criteria..:-(
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-10-20 : 13:44:42
just use SELECT...INTO
SELECT * INTO Yourdestination tableFROM(SELECT columns...,'Target' AS BuildIndFROM PHONE_VERSIONSJOIN TARGETSBUILTVIEWON phone_versions.phonebuild=targetsbuiltVIEW.phonebuildUNION ALLSELECT columns...,'SBA'FROM SBABUILD_versionsJOIN SBATARGETSBUILTVIEWON sbabuild_versions.phonebuild=sbatargetsbuilt.phonebuild)t