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.
| Author |
Topic |
|
pankaj.pareek@sparrowi.co
Starting Member
26 Posts |
Posted - 2007-03-20 : 03:27:04
|
| Help me guysA table have 5 records only and you have to show 6 records using select query without inserting the record in the database and that record is not present in the database.Eg.Table Structure: tab1id name company salary1 Pankaj ABC 9992 Amit XYZ 8883 Sanjay QWE 98754 Raj YUT 4565 Dev PLKUY 6547After runnig sql query a additional record is also shown with all the above five records but that record is not present in the table.Eg. Outputid name company salary1 Pankaj ABC 9992 Amit XYZ 8883 Sanjay QWE 98754 Raj YUT 4565 Dev PLKUY 65476 XXX XXXX XXXXThanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-20 : 03:33:51
|
[code]select id, name, company, salaryfrom tab1union allselect 6, 'XXX', 'XXXX', 'XXXX'[/code] KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-20 : 04:08:27
|
| This smells like homework too.Peter LarssonHelsingborg, Sweden |
 |
|
|
pankaj.pareek@sparrowi.co
Starting Member
26 Posts |
Posted - 2007-03-21 : 00:10:42
|
| Thank you very much:) |
 |
|
|
pankaj.pareek@sparrowi.co
Starting Member
26 Posts |
Posted - 2007-03-21 : 01:51:32
|
| Another help neededI need to insert data that is already in the table but with updated id.Eg.Table Structure: tab1id name company salary1 Pankaj ABC 9992 Amit XYZ 8882 Roy XYZ 8883 Sanjay QWE 98754 Raj YUT 4562 Jack POI 8885 Dev PLKUY 6547now what I need is to insert all the records whose id = 2 with new id = 8 in the same table.Eg. Outputid name company salary1 Pankaj ABC 9992 Amit XYZ 8882 Roy XYZ 8883 Sanjay QWE 98754 Raj YUT 4562 Jack POI 8885 Dev PLKUY 65478 Amit XYZ 8888 Roy XYZ 8888 Jack POI 888Thanks |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-21 : 01:56:12
|
If your id column is not IDENTITY column, this should work:INSERT INTO TAB1([ID], [NAME], COMPANY, SALARY)SELECT 8, [NAME], COMPANY, SALARYFROM TAB1WHERE [ID] = 2 Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
pankaj.pareek@sparrowi.co
Starting Member
26 Posts |
Posted - 2007-03-21 : 02:05:35
|
| Thank you and I will remember your word UNTRIED. |
 |
|
|
pankaj.pareek@sparrowi.co
Starting Member
26 Posts |
Posted - 2007-03-21 : 02:36:29
|
| Hi,I need a help to automatically import the data from txt (, seprated) file from specific folder at regular interval into the sqlserver 2000 database table.This is possiable?Thanks |
 |
|
|
|
|
|
|
|