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 |
|
nsrao_1975
Starting Member
13 Posts |
Posted - 2004-02-17 : 01:29:57
|
| hi, i want to fetch the entire row into a variable and refer each column for further manipulation as we do in oracle like under currow emp%rowtype and later IF emp.deptid <> 'Accounts' ... but in sqlserver i could not find any similar datatype to fetch the entire row into a variable.. can any guru helpmeout here...? Thanks in advance |
|
|
VyasKN
SQL Server MVP & SQLTeam MVY
313 Posts |
Posted - 2004-02-17 : 05:51:47
|
| No such datatype in SQL Server. You could get all the columns of a row into variables though, as shown below:DECLARE @Col1 int, @Col2 intSELECT @Col1 = Col1, @Col2 = Col2FROM YourTableWHERE Coln = 12345--HTH,Vyashttp://vyaskn.tripod.com |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-02-17 : 06:30:58
|
| Why would you want to do that?currow implies cursor processing I thinkYou can create a table variable or temp table and insert a row from the table into it.select * into #a from tbl where pk = @myrowBut why not just refer to the row in the table using the PK intead?IF emp.deptid <> 'Accounts' ...becomesif not exists (select * from emp where pk = @myrow and emp.deptid <> 'Accounts')==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|