Author |
Topic |
bkbinani
Starting Member
15 Posts |
Posted - 2011-12-07 : 08:31:01
|
Dear Expert,I m in little bit trouble. I wish to create a view with addtional logical field (BIT) which is not in primary (sourc Table)I used following Codes but not success. declare @lyn bitset @lyn=0create view vew_mst_led asselect @lyn as YES_NO ,cled_name,cled_code,nled_type,nled_bal from mst_led Please help. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-07 : 08:34:50
|
you can use variable inside view like this. you need to include value as a constant or use procedure instead.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
bkbinani
Starting Member
15 Posts |
Posted - 2011-12-07 : 08:43:50
|
quote: Originally posted by visakh16 you can use variable inside view like this. you need to include value as a constant or use procedure instead.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Thanx Sir. My hats off 2 u. Great that u r MVP.Your reply is not clear to me as I m Not expert rather I m Novice. Plz give more light. I wud grateful for your response with example.TIA |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-07 : 08:51:10
|
you need to write it as a procedure if you want to use variables like thiscreate proc vew_mst_led @lyn bit=0asselect @lyn as YES_NO ,cled_name,cled_code,nled_type,nled_bal from mst_led go ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
bkbinani
Starting Member
15 Posts |
Posted - 2011-12-07 : 09:03:09
|
quote: Originally posted by visakh16 you need to write it as a procedure if you want to use variables like thiscreate proc vew_mst_led @lyn bit=0asselect @lyn as YES_NO ,cled_name,cled_code,nled_type,nled_bal from mst_led go Thanx sir.But wud it be a 'view'. I wish to use VIEW for different purspose.Please------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-07 : 09:07:27
|
you cant have a variable inside view. view is just a virtual table with definition. you cant make it interactive by adding variables etc.for that you've to use procedures like what i've shown.Who suggested you to use view for above scenario?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
bkbinani
Starting Member
15 Posts |
Posted - 2011-12-08 : 07:24:09
|
quote: Originally posted by visakh16 you cant have a variable inside view. view is just a virtual table with definition. you cant make it interactive by adding variables etc.for that you've to use procedures like what i've shown.Who suggested you to use view for above scenario?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/Thanx sir.There was a confusion with Temp Table VS. View. I was taking view table as tmp. Sorry for troubl.Very very thanx for your reply to make me understand.Nice. Hope 2 c again.
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 07:36:01
|
no problemyou're welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|