October 27, 2006 at 4:51 am
hi
how can i insert two record and change the value
eg i have 500 records
col1 col2
abc 101
def 201
ghi 301
till 500 records
i need to insert
col1 col2
abc 101
abc 102
abc 103
def 201
def 202
def 203
ghi 301
ghi 302
ghi 303
thanxs
October 27, 2006 at 5:10 am
Something like:
-- *****************
-- Test Data
DECLARE @t TABLE
(
col1 CHAR(3) NOT NULL
,col2 SMALLINT NOT NULL
)
INSERT @t
SELECT 'abc', 101 UNION ALL
SELECT 'def', 201 UNION ALL
SELECT 'ghi', 301
-- End of Test Data
-- *****************
-- Use your table and column names here
INSERT @t
SELECT T.col1, T.col2 + N.Num
FROM @t T
CROSS JOIN (
SELECT 1
UNION ALL
SELECT 2 ) N (Num)
-- Show result
SELECT *
FROM @t
ORDER BY col1, col2
October 27, 2006 at 8:18 pm
hi
this gives me error
insert into Criticaland_INportantinsert -------- table to be inserted or dup table
select [f1],
[Mainenance Plan category],
[Maintenace Plan Description],
[Functional location],
[Equipment No KKS],
[Equipment internal number],
[Tasklist Type],
[Tasklist Group],
[Group Counter],
[Maintenance cycle],
[Cycle Unit],
[Call horizon],
[Scheduling period],
[Unit],
[Completion Requirement],
[f16]
from Criticaland_INportant --------------this the table from where i get data
(
select [f1],
[Mainenance Plan category],
[Maintenace Plan Description],
left([Functional location], 3) car,
convert(varchar, 1 + cast(substring([Functional location], 4, 2) as int)) newserial,
substring([Functional location], 6, 8000) oldFunctional_location,
substring([Equipment No KKS], 3, 8000) Equipment_No_KKS
from Criticaland_INportantinsert
  x
error
Server: Msg 156, Level 15, State 1, Line 18
Incorrect syntax near the keyword 'select'.
Server: Msg 170, Level 15, State 1, Line 26
Line 26: Incorrect syntax near ')'.
or
select [f1],
[Mainenance Plan category],
[Maintenace Plan Description],
left([Functional location], 3) car,
convert(varchar, 1 + cast(substring([Functional location], 4, 2) as int)) newserial,
substring([Functional location], 6, 8000) oldFunctional_location,
substring([Equipment No KKS], 3, 8000) Equipment_No_KKS,
[Equipment internal number],
[Tasklist Type],
[Tasklist Group],
[Group Counter],
[Maintenance cycle],
[Cycle Unit],
[Call horizon],
[Scheduling period],
[Unit],
[Completion Requirement],
[f16]
from Criticaland_INportant
error
Server: Msg 212, Level 16, State 1, Line 1
Expression result length exceeds the maximum. 8000 max, 16000 found.
Server: Msg 212, Level 16, State 1, Line 1
Expression result length exceeds the maximum. 8000 max, 16000 found
thanxs
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply