Tag: database

How to restore a SQL Server 2012 database to SQL Server 2008 R2?

I am trying to restore the backup taken from a SQL Server 2012 to SQL Server 2008 R2, and it giving an error Specified cast is not valid. (SqlManagerUI) If you have any solution to this please give comment thanks.

Why OBJECT_ID used while checking if a table exists or not

I need to check if a table in sql exist or not. If not it must create one automatically. Now I researched and found this coding: IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[YourTable]’) AND type in (N’U’)) BEGIN CREATE TABLE [dbo].[YourTable]( …. …. …. ) END Can anyone explain why it […]

MSSQL export database with data

How can I export my 2012 database with data to a .sql file so I can import it to a 2008 server? I’ve never been able to export the data only the structure.

Override file while backup database

I want to back up a database using this code sqlcmd -S servername -Q “BACKUP DATABASE [DBName] TO DISK = ‘C:\backup.bak'” It works. But if the backup file already exists, the data gets appended to the file instead of replacing the file. Every time I call BACKUP DATABASE the file gets bigger. Is there an […]

How to backup Sql Server to sql file?

In “Back UP” I only get a bak file, but I would like to create .sql file

Error restoring database backup

I am getting an error using SQL Server 2012 when restoring a backup made with a previous version (SQL Server 2008). I actually have several backup files of the same database (taken at different times in the past). The newest ones are restored without any problems; however, one of them gives the following error: System.Data.SqlClient.SqlError: […]

Restore database backup over the network

How do you restore a database backup using SQL Server 2005 over the network? I recall doing this before but there was something odd about the way you had to do it.

Change primary key column in SQL Server

UPDATE Here are the constraints as a result of the query SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = ‘history’ CONSTRAINT_NAME COLUMN_NAME ORDINAL_POSITION PK_history userKey 1 PK_history name 2 Here is the result of the query SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME = ‘history’ CONSTRAINT_NAME CONSTRAINT_TYPE IS_DEFERRABLE INITIALLY_DEFERRED PK_history PRIMARY KEY NO NO END UPDATE My […]

“The transaction log for database is full due to 'LOG_BACKUP'” in a shared host

I have an Asp.Net MVC 5 website with EntityFramework codefirst approach in a shared hosting plan. It uses the open source WebbsitePanel for control panel and its SQL Server panel is somewhat limited. Today when I wanted to edit the database, I encountered this error: The transaction log for database ‘db_name’ is full due to […]

Best use of R and SQL if restricted to a local machine

I’m trying to improve my workflow, and am hoping the community can provide insights since I am relatively new to “big data”. I typically download several dataframes from public sources which can be related to one another. After pulling several dataframes, I do various data-processing steps (e.g., filtering, sorting, aggregating, custom calculations) before doing regression […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.