Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
DoctorsAvailability		
DoctorsId	int	Primary Key
NonAvailability	nvarchar(100)	not null
Mon	nvarchar(100)	not null
Tue	nvarchar(100)	not null
Wed	nvarchar(100)	not null
Thur	nvarchar(100)	not null
Fri	nvarchar(100)	not null
Sat	nvarchar(100)	not null
Sun	nvarchar(100)	not null

The above one is my table, now i want to read the particular column name like Mon or Tue or web etc... using stored procedure and in my table I am having some data inserted in day columns, when I pass the parameter like Mon i need to get the data present in the Mon column
Posted
Updated 5-Jun-12 3:21am
v2

try the following...

SQL
CREATE PROCEDURE GetMyData @Day int
AS
SELECT @Day FROM DoctorsAvailability 
GO


You need to pass 4 for Monday 5 for tuesday etc....

I am not sure of this logic, and i am unable to test it as i don't have sql server here...


Regards
Sebastian
 
Share this answer
 
try this

SQL
CREATE PROCEDURE GetMyData @Day int
AS

DECLARE @SQL NVARCHAR(MAX)

SET @SQL=' 
SELECT '+@Day+' FROM DoctorsAvailability
'

EXEC(@SQL)

GO
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900