Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALTER PROCEDURE [dbo].[InsertStudentDetails]
- @valueList varchar(8000),
- @Username NVarChar(55)
- AS
- BEGIN
- Declare @sql nvarchar(max),
- @DynamicSQL nvarchar(max),
- @pos INT,
- @len INT,
- @value varchar(10),
- @list varchar(max),
- @Table_Name varchar(255),
- @ans nvarchar(55),
- @subject_name nvarchar(255)
- set @pos = 0
- set @len = 0
- set @list=''
- WHILE CHARINDEX(',', @valueList, @pos + 1) > 0
- BEGIN
- set @len = CHARINDEX(',', @valueList, @pos+1) - @pos
- set @value = SUBSTRING(@valueList, @pos, @len)
- if isnumeric(@value) = 0
- begin
- set @Table_Name = @value
- end
- if isnumeric(@value) = 1
- begin
- set @list= @list + @Table_Name + '-' + @value + '-' + '*' + '-
- end
- if left(@Table_Name,1)='P' and isnumeric(@value)=1
- begin
- set @subject_name='RNSNEETJEEPhysics.dbo.'+ @Table_Name
- SELECT @ans =ans FROM **[ ' + @subject_name + ']** WHERE id = @value
- set @list= @list + @ans + '-'
- end
- set @pos = CHARINDEX(',', @valueList, @pos+@len) +1
- End
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement