| Author |
Topic |
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-01-29 : 18:15:21
|
| Hello,Why would this issue syntax errors? How can it be made to work?DECLARE @TKey as BigIntDECLARE @TName as VARCHAR(32)DECLARE @Tid AS VARCHAR(32)SET @TKey=99SET @TName='TestTABLE'SET @Tid='TestTABLEID'SET IDENTITY_INSERT @TName ONINSERT INTO @TName (@Tid) VALUES (@TKey) SET IDENTITY_INSERT @TName OFF--PhB |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-01-29 : 18:18:48
|
| Because you need dynamic SQL to do this.Why do you need the table name to be dynamic?Tara Kizer |
 |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-01-29 : 19:39:54
|
| Because I want this to be a generic SP for adding records to tables?Is there a way to do this with T-SQL?--PhB |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-01-29 : 19:59:02
|
| You forgot one more 'very' :)I see. I'm going to have to see what I can come up without using D-SQL.--PhB |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-29 : 20:13:21
|
quote: Originally posted by phrankbooth You forgot one more 'very' :)I see. I'm going to have to see what I can come up without using D-SQL.--PhB
Please do share with us if you have a solution to this without using Dynamic SQL  KH |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-01-29 : 21:51:16
|
quote: Originally posted by khtan
quote: Originally posted by phrankbooth You forgot one more 'very' :)I see. I'm going to have to see what I can come up without using D-SQL.--PhB
Please do share with us if you have a solution to this without using Dynamic SQL  KH
I have a solution : normalize the database.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-29 : 22:12:17
|
quote: Originally posted by jsmith8858I have a solution : normalize the database.- Jeffhttp://weblogs.sqlteam.com/JeffS
+ 1Yes. And a good solution  KH |
 |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2007-01-30 : 10:14:16
|
| Normalization would be good if the db could be further normalized. But it's a simple db with three tables, the tables each have keys and are atomized.I think I will just handle it by adding an SP for each table. The DB it's small enough to do that, so no big hassle, I had just wanted to try to be as generic as I could but SQL won't let me.Thanks in any case for you help.--PhB |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-30 : 10:18:07
|
| Sometimes being too generic will cost you more than benefiting, and this is one of those cases.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|