Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
yaman
Posting Yak Master
213 Posts |
Posted - 2008-07-23 : 02:09:59
|
| ALTER PROCEDURE [dbo].[Stp_StatusAdd] @OrgId nvarchar(10), @LanguagePostfix nvarchar(10), @StatusName nVarchar(100), @Status int OUTPUTASBEGINDECLARE @StatusName1 NVARCHAR(100),@a varchAR(10)Set @StatusName1 = 'Status_' + @LanguagePostfix if not exists(Select * from tbl_status where @StatusName1=@StatusName and orgid=@orgid)Begin DECLARE @SQLString NVARCHAR(1000)SET @SQLString = N'INSERT INTO tbl_Status(OrgId ,' +@StatusName1+') VALUES(@OrgId , @StatusName )';DECLARE @parmDefinition NVARCHAR(500)SET @parmDefinition =N'@OrgID nvarchar(10),@StatusName Varchar(100)';EXECUTE sp_executeSQL @SQLString,@parmDefinition,@OrgID=@OrgID,@StatusName=@StatusName;Set @Status = (SELECT max(Status) FROM tbl_status)ENDThis is used to insert record in tbl_status if record already exists then procedure cannot insert record else inert record But procedure cannot working Bcoz This line cannot working pls help me out if not exists(Select * from tbl_status where @StatusName1=@StatusName and orgid=@orgid)Yaman |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-07-23 : 02:15:41
|
| is @statusname1 a column name then? you'll need to build it in dynamic sql the same way you did in the insert statementEm |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-23 : 03:40:34
|
| www.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-23 : 04:10:26
|
| what is the error you're getting? |
 |
|
|
|
|
|