Click here to Skip to main content
15,904,023 members

Comments by Heino Zunzer (Top 16 by date)

Heino Zunzer 25-Jan-12 6:02am View    
have you tried any of these statements? Not one of them works!
Heino Zunzer 23-Jan-12 11:08am View    
You do realise that both above queries only work with the specific data you have entered?
Try changing the data to
id action value
1 BEGIN 9
1 END 16
2 BEGIN 20
2 END 25
1 BEGIN 10
1 END 15
and you'll see that you still have no solution, since the main problem is the same ID for lines 1, 2, 5 and 6.
Heino Zunzer 23-Jan-12 7:09am View    
with
SET IDENTITY_INSERT books ON
you can insert any number into an autoincrement (identity) field. after you have done your inserts
SET IDENTITY_INSERT books OFF
will switch the autoincrement on again.

Using identity columns is always best practise. Using GUIDS worst practise. GUIDS are basically char columns and joining and searching on GUIDs takes much longer than on integer columns. also GUIDs are random and not in ascending order, which a primary key, espescially a clustered one, always should be.

and don't even get me started on the idea with creating a new table. just set identity_insert on and insert your values. as easy as that.
Heino Zunzer 19-Jan-12 12:24pm View    
You can either use sqlcmd command line tool (http://msdn.microsoft.com/en-us/library/ms162773.aspx) or use the same method you are using in your code to connect to the Sql Server.
Heino Zunzer 23-Nov-11 12:22pm View    
even easier. the @nums part is only to get the things into a temporary table. if it already is a table or a query result, forget the first part.

declare @tabNums table (Num int primary key clustered not null)

insert @tabNums (Num)
select yourNumColumn
from yourTable;

and then go on with the cursor (from -- now check for holes in the chain)