| 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.likeexec SP 00004it will print:select * from table where idname = 4i want it to printselect * 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 printChiraghttp://chirikworld.blogspot.com/ |
 |
|
|
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 LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-10 : 14:13:03
|
| set @tableName = '00005'Peter LarssonHelsingborg, Sweden |
 |
|
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2006-10-10 : 14:35:27
|
| declare @townID varchar(25)set @townID = '''00005'''print @townIDif exists (select * from sysobjects where xtype= 'u' and name = @townID)drop table @townIDwhy am i getting a syntax error.? |
 |
|
|
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 @townIDif exists (select * from sysobjects where xtype= 'u' and name = @townID)declare @sql nvarchar(100)set @sql = N'drop table ' + @townIDexec sp_executesql @sql |
 |
|
|
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 LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
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 LarssonHelsingborg, Sweden |
 |
|
|
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 LarssonHelsingborg, 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 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|