Click here to Skip to main content
15,885,435 members
Home / Discussions / Database
   

Database

 
AnswerRe: How can i select all dates between date range? Pin
vvashishta18-Jun-12 20:09
vvashishta18-Jun-12 20:09 
Questionhow to make a duplicate database with new name in SQL Server 2008 Pin
nvarunkumar15-Jun-12 0:06
nvarunkumar15-Jun-12 0:06 
AnswerRe: how to make a duplicate database with new name in SQL Server 2008 Pin
Sandeep Mewara15-Jun-12 1:11
mveSandeep Mewara15-Jun-12 1:11 
GeneralRe: how to make a duplicate database with new name in SQL Server 2008 Pin
nvarunkumar15-Jun-12 2:04
nvarunkumar15-Jun-12 2:04 
GeneralRe: how to make a duplicate database with new name in SQL Server 2008 Pin
nvarunkumar18-Jun-12 21:59
nvarunkumar18-Jun-12 21:59 
AnswerRe: how to make a duplicate database with new name in SQL Server 2008 Pin
Paul Conrad19-Jun-12 8:22
professionalPaul Conrad19-Jun-12 8:22 
GeneralRe: how to make a duplicate database with new name in SQL Server 2008 Pin
nvarunkumar19-Jun-12 21:31
nvarunkumar19-Jun-12 21:31 
QuestionIn SQL Server, how to generate table script as a single statement? Pin
dexterama14-Jun-12 3:24
professionaldexterama14-Jun-12 3:24 
I am attempting to put a database into the Data-Tier application model, and the wizards (being MS Wizards) are painful and lack error reporting.

So, I'm trying to export my database as scripts, and import the scripts into the DAC model.

Here's the problem: over the years, our tables have undergone modifications. What I don't get is why SQL Server seems to have to regenerate a table from script in sequence (here's a sample)
SQL
CREATE TABLE [dbo].[SampleUserMaster](
    [SampleUserMasterKey] [dbo].[udt_keyfield] IDENTITY(1,1) NOT NULL,
    [UserKey] [dbo].[udt_keyfield] NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NULL,
    [SampleKey] [dbo].[udt_keyfield] NOT NULL,
    [UserMasterKey] [dbo].[udt_keyfield] NULL,
    [AddressRefusedUnknownFlag] [dbo].[udt_logical] NULL,
    [SampleCompletedFlag] [dbo].[udt_logical] NULL,
    [SampleCompletedDate] [datetime] NULL,
    [IncomingSampleActionDate] [datetime] NULL,
    [IncomingSampleActionCodesKey] [dbo].[udt_keyfield] NULL,
    [IncomingSampleActionCode] [dbo].[udt_sharedcode] NULL,
    [IncomingSampleActionDescription] [dbo].[udt_sharedcodedescription] NULL,
    [LockSession] [uniqueidentifier] NULL,
    [LockTime] [datetime] NULL,
    [LockVersion] [timestamp] NOT NULL,
    [WWClearanceCodeKey] [dbo].[udt_keyfield] NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[SampleUserMaster] ADD [WWClearanceCode] [dbo].[udt_sharedcode] NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [WWClearanceDescription] [dbo].[udt_sharedcodedescription] NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [WWClearanceCodeDateTime] [datetime] NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [WWClearanceCodeAuthorityInvolvedKey] [dbo].[udt_keyfield] NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [IsElligibleWorkRelease] [dbo].[udt_logical] NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [DepartmentKey] [dbo].[udt_keyfield] NOT NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [CreatedDateTime] [datetime] NOT NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [ModifiedDateTime] [datetime] NOT NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [VisitorListLastChangedDateTime] [datetime] NULL
ALTER TABLE [dbo].[SampleUserMaster] ADD [IsSealed] [bit] NULL
 CONSTRAINT [PK_SampleUserMasterkey] PRIMARY KEY CLUSTERED
(
    [SampleUserMasterKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


Note the alter table statements for each column added over time - why is this???!?!?!

I have 20,000+ tables, so obviously I can't manually edit these to move the added columns into the definition itself - is there a way to make it generate a table as a table without all the alter table commands for added columns? Any ideas?

This fails Data-Tier Application importing; it will not run any of the alter table statements, thus these columns never make the model, thus the stored procs and views fail whereas they reference missing columns.

Is there a way to generate a CREATE TABLE statement with ALL Columns in is? I don't get the way it does it now... Thanks in advance.

I've exported the DB, and restored it and it still keeps the full history of alters to add columns, and generates them as individual statements....
Think of how stupid the average person is, and realize half of them are stupider than that. - George Carlin

AnswerRe: In SQL Server, how to generate table script as a single statement? Pin
PIEBALDconsult14-Jun-12 4:09
mvePIEBALDconsult14-Jun-12 4:09 
GeneralRe: In SQL Server, how to generate table script as a single statement? Pin
dexterama14-Jun-12 5:50
professionaldexterama14-Jun-12 5:50 
AnswerRe: In SQL Server, how to generate table script as a single statement? Pin
Mycroft Holmes15-Jun-12 13:38
professionalMycroft Holmes15-Jun-12 13:38 
Questioni want to do left join that should not return same multiple rows Pin
asifkhan114-Jun-12 1:45
asifkhan114-Jun-12 1:45 
AnswerRe: i want to do left join that should not return same multiple rows Pin
DRKARTHIKRAJ14-Jun-12 2:32
DRKARTHIKRAJ14-Jun-12 2:32 
AnswerRe: i want to do left join that should not return same multiple rows Pin
asifkhan114-Jun-12 3:09
asifkhan114-Jun-12 3:09 
GeneralRe: i want to do left join that should not return same multiple rows Pin
DRKARTHIKRAJ15-Jun-12 1:53
DRKARTHIKRAJ15-Jun-12 1:53 
AnswerRe: i want to do left join that should not return same multiple rows Pin
Eddy Vluggen14-Jun-12 2:39
professionalEddy Vluggen14-Jun-12 2:39 
AnswerRe: i want to do left join that should not return same multiple rows Pin
Nolan Sunico14-Jun-12 5:03
Nolan Sunico14-Jun-12 5:03 
AnswerRe: i want to do left join that should not return same multiple rows Pin
Michael Potter15-Jun-12 10:43
Michael Potter15-Jun-12 10:43 
QuestionFinding "Missing" ID Numbers in Table (SQL Server 2005) Pin
Peter Bamuhigire13-Jun-12 7:25
Peter Bamuhigire13-Jun-12 7:25 
AnswerRe: Finding "Missing" ID Numbers in Table (SQL Server 2005) Pin
Mycroft Holmes13-Jun-12 14:45
professionalMycroft Holmes13-Jun-12 14:45 
AnswerRe: Finding "Missing" ID Numbers in Table (SQL Server 2005) Pin
Eddy Vluggen14-Jun-12 0:59
professionalEddy Vluggen14-Jun-12 0:59 
QuestionView might cause corruption? Pin
kmoorevs13-Jun-12 5:35
kmoorevs13-Jun-12 5:35 
AnswerRe: View might cause corruption? Pin
David Mujica13-Jun-12 5:56
David Mujica13-Jun-12 5:56 
AnswerRe: View might cause corruption? Pin
Pete O'Hanlon13-Jun-12 5:57
mvePete O'Hanlon13-Jun-12 5:57 
AnswerRe: View might cause corruption? Pin
Corporal Agarn13-Jun-12 5:57
professionalCorporal Agarn13-Jun-12 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.