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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Need to create new records based on result set

Author  Topic 

dba123
Yak Posting Veteran

90 Posts

Posted - 2005-12-16 : 00:24:00
Let's say I do a select statement and the results are

Acct # Zip Phone Addr
11223 23232 333-444-5555 6556 Duns Rd.
12345 34343 222-444-3333 1000 Aspire Blvd.

I need to create a record into a final table using the Acct # and column for each column as well as append some other values like this

11223 23232 othervalue1 othervalue2
11223 333-444-5555 othervalue1 othervalue2
11223 6556 Duns Rd. othervalue1 othervalue2
12345 34343 othervalue1 othervalue2
12345 222-444-3333 othervalue1 othervalue2
12345 1000 Aspire Blvd. othervalue1 othervalue 2

How do I do this for each row in my result set?

surendrakalekar
Posting Yak Master

120 Posts

Posted - 2005-12-16 : 00:37:01
Not clear but try this.
Select str([acct #]) + space(1) + OtherValue1 + space(1) + othervalue2 from yourtable where ....

Surendra
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-16 : 01:20:04
Where do you want to show these data?

>>Select str([acct #]) + space(1) + OtherValue1 + space(1) + othervalue2 from yourtable where ....

Str will unnecessarily add leading and trailing spaces

select str(10)+str(12)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -