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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 input parameter doesn't show.

Author  Topic 

funketekun
Constraint Violating Yak Guru

491 Posts

Posted - 2006-10-10 : 09:59:05
when i pass a input parameter, the SP doesn't recognize it.

like

exec SP 00004

it will print:
select * from table where idname = 4

i want it to print
select * from table where idname = '00004'

how can i do that?

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-10-10 : 10:03:05
convert to varchar and then print

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-10 : 10:06:05
exec SP '00004'
and make sure the parameter is varchar.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-10 : 10:10:44
Give us a code snipet so we can actually see where the problem lies?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-10 : 14:13:03
set @tableName = '00005'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

funketekun
Constraint Violating Yak Guru

491 Posts

Posted - 2006-10-10 : 14:35:27
declare @townID varchar(25)
set @townID = '''00005'''
print @townID
if exists (select * from sysobjects where xtype= 'u' and name = @townID)
drop table @townID



why am i getting a syntax error.?
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-10-10 : 14:53:49
You'll need to make that dynamic SQL. Also, not sure why you have three quotes on either side of your townID, you should only need one?


declare @townID varchar(25)
set @townID = '00005'
print @townID
if exists (select * from sysobjects where xtype= 'u' and name = @townID)
declare @sql nvarchar(100)
set @sql = N'drop table ' + @townID
exec sp_executesql @sql
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-10 : 15:59:26
Use [ and ] around the table name or you will trigger an error. For some reason this happens when table names are all digits.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-10 : 16:01:30
I believe it's only when it starts with a numeric...DB2 is the same way

But honestly, what's with the naming "convention"?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-10 : 16:08:02
Read last half thousand post user Gonxia649 has made and you will understand...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-10-10 : 16:54:20
quote:
Originally posted by Peso

Read last half thousand post user Gonxia649 has made and you will understand...


Peter Larsson
Helsingborg, Sweden



There's no error so trivial that he can’t make it again and again.

And ask for help on it again and again. Kind of sad, really.




CODO ERGO SUM
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-10 : 17:12:33
Something is weird. Not only table names are the same, also the logic and everything found here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=72882#260447


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -