Procedure or T-SQL to build new table

  • If EventID is "int" then you can solve the problem with the in ( ) operator. Charindex construct was for character values

    You should look at the details:

    at the begining of the proc

    DECLARE @EventID varchar(500)

    ...

    at the end of the proc as you noted this time :

    -- select @SqlString

    exec sp_executeSql @SqlString, N'@FieldID int, @EventID int', @FieldID, @EventID

    Which is going to be?


    * Noel

  • No he's trying to pass in a comma separated list of integers.

    He's got a poorly defined schema, where "Fields" for a virtual table are defined as rows in a table, and values for those fields reference fieldid's in another table, So now he's trying to extract the "Field" information in a conventional Table Format.

    IE

    Fields

    1 FirstName

    2 LastName

    3 BirthDate

    Values

    1 'Joe'

    2 'Somebody'

    3 '01/01/1766'

    Result

    FirstName LastName BirthDate

    Joe  Somebody 01/01/1766

    The varchar(500) declaration is fine to jold the comma separated list of id's, then concatenated into the sql string.

    There's so many posts flying I'm sure hes thoroughly confused by now.

  • I can't stay that patient when someone snaps at me .

    That's why I didn't tell him that this proc is crap...

  • How do you know the type of the column EventID ?


    * Noel

  • Way to stick it in there .

    I feel I must point this out at this point.

    When you see yourself in the face of an impossibly complicated task, look at a way to simplify the task or avoid it altogether.

  • I told the dude before I started helping him that his schema was crap, and he needed to do some table modeling.

  • N I C E !


    * Noel

  • Simplicity is the golden rule in sql server.

    He'll get this eventually. Maybe after 2-3 weeks of trying to make this work and failing.

  • I see this alot, people need Dynamic sql to solve problems where they are trying to build an application so obscure that there is no known values.

    If you try to build an app to rule them all, It will probably be ruled by all.

     

  • Hehe, sounds like an horror story I heard about our governement. They wanted to merge all the applications used by all the departements into one huge software. A few (500-600) millions later, they discovered that this wasn't possible, nor advisable .

  • It has happened more than what we all think


    * Noel

  • It's surely not something you brag about .

  • No but when it happens the burst is so massive that lots of people know about it


    * Noel

  • Let's say we have front row tickets for those kind of events.

  • LOL


    * Noel

Viewing 15 posts - 46 through 60 (of 69 total)

You must be logged in to reply to this topic. Login to reply