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 |
|
FrankC
Starting Member
2 Posts |
Posted - 2009-07-08 : 13:07:24
|
| Hello, I am new to TSQL.I need to create a stored proc that will return records. I would like to return back AccountID, FirstName, LastName & email.For example, I am comparing two tables using the AccountID fields.So currently my query is:Select AccountID, FirstName, LastName, emailfrom tblCustomersWhere AccountID not in (select AccountID from tblVendors) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 13:12:32
|
what will you be passing as input to sp? Account ID? if yes, it would be likeCREATE PROC GetData@AccountID intASBEGINSelect AccountID, FirstName, LastName, emailfrom tblCustomersWhere AccountID =@AccountIDENDGO |
 |
|
|
FrankC
Starting Member
2 Posts |
Posted - 2009-07-08 : 13:15:07
|
| not passing anything. This is just comparing two tables, so I dont think I need to pass anything |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-07-08 : 13:30:18
|
then this is enough CREATE PROC GetDataASBEGINSelect AccountID, FirstName, LastName, emailfrom tblCustomersWhere AccountID not in(select AccountID from tblVendors)ENDGO you can also use NOT EXISTS or LEFT JOIN instead of NOT IN |
 |
|
|
|
|
|
|
|