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-05-02 : 04:20:28
|
| set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER proc [dbo].[stp_Level1Add]@Level1Name varchar(100),@LanguageID int,@OrgID int,@Level1ID int OUTPUTasDeclare @LanguagePostfix varchar(5),@str VARCHAR(400)SET @STR='INSERT INTO tbl_Level1'set @LanguagePostfix = (select Postfix from tbl_Language where langID = @LanguageID)Declare @columnName varchar(20)set @columnName = 'Level1Name_' + @LanguagePostfixprint @columnName--print @columnnameif not exists(select * from tbl_Level1 where @columnName=@Level1Name and orgID=@OrgID)beginSET @STR='INSERT INTO tbl_Level1' + '(' + @columnName + ',orgID' + ')' + 'Values' + '(' +@Level1Name+ ',' + @orgID + ')'EXEC @STRSELECT @Level1ID=SCOPE_IDENTITY()end------------------------------------------------- EXEC--------------------EXEC @return_value = [dbo].[stp_Level1Add] @Level1Name = N'General Administrative Department', @LanguageID = 1, @OrgID = 1, @Level1ID = @Level1ID OUTPUT--------------------------------------------------- ERROR-----------------------Conversion failed when converting the nvarchar value 'INSERT INTO tbl_Level1(Level1Name_HIN,orgID)Values(General Administrative Department,' to data type int.----------------------------Yaman |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-05-02 : 04:30:27
|
This would probably do the trick:SET @STR='INSERT INTO tbl_Level1 (' + @columnName + ', orgID) Values (''' +@Level1Name+ ''',' + @orgID + ')'EXEC @STR--Lumbago |
 |
|
|
yaman
Posting Yak Master
213 Posts |
Posted - 2008-05-02 : 04:37:36
|
| Sir Still Error Conversion failed when converting the nvarchar value 'INSERT INTO tbl_Level1 (Level1Name_ENG, orgID) Values ('General Administrative Department',' to data type int.Yaman |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-05-02 : 04:47:48
|
| What does PRINT @STR give you?--Lumbago |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-02 : 04:59:59
|
| Dup post:-http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=102121 |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-05-02 : 05:10:35
|
| Aaaargh! Hate that--Lumbago |
 |
|
|
yaman
Posting Yak Master
213 Posts |
Posted - 2008-05-02 : 05:34:49
|
| Sir Its Not Print The Statement Its Gives A error Conversion failed when converting the nvarchar value 'INSERT INTO tbl_Level1 (Level1Name_ENG, orgID) Values ('General Administrative Department',' to data type int.Yaman |
 |
|
|
|
|
|
|
|