How can I generate an INSERT script for an existing SQL Server table that includes all stored rows?

I’m looking for a way to generate a “Create and insert all rows” script with SQL Management Studio 2008 R2. I know that I can create a “create table” script. I can also create an “insert in” script, but that will only generate a single row with placeholders. Is there a way to generate an … Read more

How to drop all tables in a SQL Server database?

I’m trying to write a script that will completely empty a SQL Server database. This is what I have so far: USE [dbname] GO EXEC sp_msforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT all’ EXEC sp_msforeachtable ‘DELETE ?’ When I run it in the Management Studio, I get: Command(s) completed successfully. but when I refresh the table … Read more

SQL Server. How to refresh the intellisense? [duplicate]

This question already has answers here: Closed 10 years ago. Possible Duplicate: Lost the IntelliSense SQL Server 2008 Intellisense problem I’m new to SQL Server, so this is probably an easy fix. In SQL Server 2008 R2, I’ve just imported a new data table and/or renamed fields in an existing table (it happens either way). … Read more

Unique constraint on multiple columns

CREATE TABLE [dbo].[user]( [userID] [int] IDENTITY(1,1) NOT NULL, [fcode] [int] NULL, [scode] [int] NULL, [dcode] [int] NULL, [name] [nvarchar](50) NULL, [address] [nvarchar](50) NULL, CONSTRAINT [PK_user_1] PRIMARY KEY CLUSTERED ( [userID] ASC ) ) ON [PRIMARY] GO How do I add a unique constraint for columns fcode, scode, dcode with t-sql and/or management studio? fcode, scode, … Read more