Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query Questionsss
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cal_bonjovi
Starting Member

3 Posts

Posted - 12/20/2010 :  04:48:23  Show Profile  Reply with Quote
i have a query with parameters, what i want is i want to give value to my parameter coming another table
example:
declare @PersonnelNumber int
declare @WageType int
declare @PayGroup nvarchar(40)

set @PersonnelNumber = 123
set @WageType = 7000
set @PayGroup = 'M'

instead of 123, i want to get its value from tableSource
instead of 7000, i want to get its value from tableSource
instead of 'M', i want to get its value from tableSource

then below this declaration query is a where a clause that uses the above parameters

like this one..but this is incorrect
set @PersonnelNumber = select personnelNumber from tableSOurce
set @WageType = select Wagetype from tableSOurce
set @PayGroup = select Paygroup from tableSOurce

Sachin.Nand
Flowing Fount of Yak Knowledge

2937 Posts

Posted - 12/20/2010 :  04:52:45  Show Profile  Reply with Quote
select @PersonnelNumber = personnelNumber from tableSOurce

Remember the value of @PersonnelNumber will be set to any of the random value of personnelNumber from tableSOurce


PBUH

Go to Top of Page

cal_bonjovi
Starting Member

3 Posts

Posted - 12/20/2010 :  04:57:51  Show Profile  Reply with Quote
how will i write that..


set @PersonnelNumber = Select @PersonnelNumber = PersonnelNumber from tableSource

????
Go to Top of Page

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 12/20/2010 :  05:34:07  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
You write it exactly how Sachin.Nand showed.

select @PersonnelNumber = personnelNumber from tableSource


--
Gail Shaw
SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000