Click here to Skip to main content
15,920,596 members
Home / Discussions / Database
   

Database

 
AnswerRe: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. Pin
Ian Uy29-Oct-07 4:51
Ian Uy29-Oct-07 4:51 
QuestionMSSQL 2005 Log File Pin
sgsofy28-Oct-07 23:56
sgsofy28-Oct-07 23:56 
AnswerRe: MSSQL 2005 Log File Pin
Mike Dimmick29-Oct-07 1:22
Mike Dimmick29-Oct-07 1:22 
GeneralRe: MSSQL 2005 Log File Pin
sgsofy31-Oct-07 7:24
sgsofy31-Oct-07 7:24 
QuestionGet value from Sub Report in SSRS Pin
QPun28-Oct-07 23:16
QPun28-Oct-07 23:16 
AnswerRe: Get value from Sub Report in SSRS Pin
QPun29-Oct-07 15:13
QPun29-Oct-07 15:13 
QuestionSlow inRetrieving data Pin
briogene28-Oct-07 22:54
briogene28-Oct-07 22:54 
AnswerRe: Slow inRetrieving data Pin
soni uma29-Oct-07 0:05
soni uma29-Oct-07 0:05 
GeneralRe: Slow inRetrieving data Pin
Colin Angus Mackay29-Oct-07 0:09
Colin Angus Mackay29-Oct-07 0:09 
GeneralRe: Slow inRetrieving data Pin
soni uma29-Oct-07 0:41
soni uma29-Oct-07 0:41 
AnswerRe: Slow inRetrieving data Pin
Colin Angus Mackay29-Oct-07 0:08
Colin Angus Mackay29-Oct-07 0:08 
AnswerRe: Slow inRetrieving data Pin
Ian Uy29-Oct-07 4:52
Ian Uy29-Oct-07 4:52 
GeneralRe: Slow inRetrieving data Pin
Colin Angus Mackay29-Oct-07 5:12
Colin Angus Mackay29-Oct-07 5:12 
QuestionDoubt in StoredProcedure [modified] Pin
John.L.Ponratnam28-Oct-07 20:37
John.L.Ponratnam28-Oct-07 20:37 
AnswerRe: Doubt in StoredProcedure Pin
neeraj_indianic28-Oct-07 21:11
neeraj_indianic28-Oct-07 21:11 
GeneralRe: Doubt in StoredProcedure Pin
neeraj_indianic28-Oct-07 23:37
neeraj_indianic28-Oct-07 23:37 
AnswerRe: Doubt in StoredProcedure Pin
N a v a n e e t h28-Oct-07 21:16
N a v a n e e t h28-Oct-07 21:16 
AnswerRe: Doubt in StoredProcedure Pin
soni uma28-Oct-07 21:22
soni uma28-Oct-07 21:22 
AnswerRe: Doubt in StoredProcedure Pin
John-ph28-Oct-07 22:38
John-ph28-Oct-07 22:38 
GeneralRe: Doubt in StoredProcedure Pin
John.L.Ponratnam28-Oct-07 22:52
John.L.Ponratnam28-Oct-07 22:52 
GeneralRe: Doubt in StoredProcedure Pin
John-ph28-Oct-07 23:24
John-ph28-Oct-07 23:24 
ok I suggest you a better way of doing this. In sql Server we have one method of executing Dynamic Sql using sp_executesql which does a parameter substution based on the parameter definition.Let us do something like this to solve your problem...

create proc sp_temp 
@columnname varchar(25),
@value varchar(25) 
as 
 
DECLARE @SQLQuery AS NVARCHAR(500)
DECLARE @ParameterDefinition AS NVARCHAR(100)
 
set @SQLQuery = 'select * from tblname where (1=1) AND ' 
 
IF @columnname = 'EmpID'
BEGIN
set @SQLQuery = @SQLQuery + @columnname + ' =  @value' 
SET @ParameterDefinition =  '@value INT'
END
 
IF @columnname = 'EmpName' 
BEGIN
set @SQLQuery = @SQLQuery + @columnname + ' = @value' 
SET @ParameterDefinition =  '@value NVARCHAR(25)'
END
 
EXECUTE sp_executesql @SQLQuery, @ParameterDefinition, @value
 
GO



Here in the above procedure I build the ParameterDefinition list with the appropriate Datatype based on the column name. And the sp_executesql would automatically do a parameter substitution based on the DataType. Jus check it out whether it works...

 Regards
 - J O H N -



QuestionDMO objects in sql 2005 Pin
ramyasangeet28-Oct-07 20:12
ramyasangeet28-Oct-07 20:12 
AnswerRe: DMO objects in sql 2005 Pin
Mike Dimmick29-Oct-07 1:30
Mike Dimmick29-Oct-07 1:30 
Questionhow to use sp_who2 and where should i put it to check ? Pin
skyleo_200828-Oct-07 16:50
skyleo_200828-Oct-07 16:50 
AnswerRe: how to use sp_who2 and where should i put it to check ? Pin
squattyarun28-Oct-07 18:57
squattyarun28-Oct-07 18:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.