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
 SQL Insert and Increment

Author  Topic 

esteiner97
Starting Member

3 Posts

Posted - 2011-12-02 : 13:14:30
I am looking for a way to automate this data entry.

SQL 2008 r2.

I have five columns in my table we care about.

1. Table_Name = Will reamin static through all entrys.
2. Value = Will increment up from only a set ### value.
3. Description = Row will increment up from a name and set ### value
4. Inactive = Will remain static
5. Related = Will remain static

Example

TABLE1 > 1 > Data 1 > N > Reference
TABLE1 > 2 > Data 2 > N > Reference
TABLE1 > 3 > Data 3 > N > Reference
TABLE1 > 4 > Data 4 > N > Reference
TABLE1 > 5 > Data 5 > N > Reference

Will need to be able to set the start and stop values as well as be able to set the word "data" to other values.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-02 : 13:18:18
[code]
DECLARE @Start int,@End int
SELECT @Start=1,@End = 5

;With CTE (N)
AS
(
SELECT @Start
UNION ALL
SELECT @Start + 1
FROM CTE
WHERE @Start + 1<= @End
)

SELECT 'TABLE1',N,'Data ' + CAST(N AS varchar(10)),'N','Reference'
FROM CTE
OPTION (MAXRECURSION 0)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

esteiner97
Starting Member

3 Posts

Posted - 2011-12-02 : 13:30:10
I have a sql assigned GUID in the first column for the Primary Key. How do I configure that in?

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-03 : 00:21:16
where's the GUID stored currently?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -