Question: Need help creating a table using the 'sp\_executesql' command in sql server and setting the seed with a variable. I get the seed I want and store it in @theSeed

```
DECLARE @theSeed int
SELECT @theSeed = (MAX([Id]) + 1) FROM [Person]

```

then i want to create the table and use this seed as the identity seed in the new table

```
EXEC sp_executesql N'CREATE TABLE [NewPerson] (
    [PersonId] [int] IDENTITY(5000 , 1) NOT NULL
PRIMARY KEY CLUSTERED 
(
    [PersonId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]'
GO

```

I need to replace the 5000 with the value in @theSeed. thanks

Answer: 
Here are the steps to get you on the right foot in C++

1. Place your string in a `std::string`
2. Using [std::string::find](http://en.cppreference.com/w/cpp/string/basic_string/find) find "{"
3. Using [std::string::find](http://en.cppreference.com/w/cpp/string/basic_string/find) again, find "}" that goes after the "{" you found in step 2
4. Use [std::string::erase](http://en.cppreference.com/w/cpp/string/basic_string/erase) to remove the chars using the information you got from step 2 and step 3

Once you have that going, you can run it to see if the speed is efficient for what you need and then you can optimize based on what the bottle neck is.
Efficiency can refer to ease of coding, cost to maintain, or speed of execution. Usually you want to strike a balance between the 3.

Because you explicitly mention string, I assume you refer to C++, not C.

In a current C++ environment, replacing "something" in a string can easily be done with string::replace, or with regular expressions (a topic for itself). 

If you want something that is harder to maintain but potentially faster, you can iterate over the string and insert or delete characters as necessary.