Backup SQL Server database from windows form application by a button click

I need to backup a database by clicking a button on the windows application form. I’m developing it on Visual Studio 2012 in C#. In Windows site, I learned to backup using Transact SQL. I tried it from Transact SQL editor in visual studio. Here is the SQL transact I used: USE TestDB; GO BACKUP […]

Relative path in t sql?

How to get the relative path in t sql? Take for example a .sql file is located in the folder D:\temp, I want to get path of the file hello.txt in the folder D:\temp\App_Data. How to use the relative path reference? Let’s say I am executing the sql file inside the SQL server management studio.

How to do nothing in SQL Server

Possible Duplicate: Empty statement in T-SQL How can I get this to compile in SQL Server? IF @value IS NULL BEGIN — I don’t want to do anything here END

Calculate the maximum storage size of table record?

Is there a way to determine what the maximum size of a record would be in SQL Server past doing it by hand? For example: CREATE TABLE test ( id INT PRIMARY KEY IDENTITY(1, 1), name VARCHAR(256), test_date DATETIME ) so, if I’m not mistaken, when calculating that by hand that record could be a […]

SQL Server CLR UDF Parallelism redux

I have been researching SQL Server CLR UDFs and parallelism for some time. The general consensus seems to be that in SQL Server 2008 and later, a scalar value CLR UDF with DataAccessKind.None should allow parallel execution. However, when I use my scalar value UDF in my view in SQL Server 2012, it still kills […]

duplicate null value violation on UNIQUE KEY constraint in Mssql

MS SQL Server does not ignore the null value and considers it as violation for the UNIQUE KEY constraint but what I know is that the UNIQUE KEY differ from the primary key where it accepts the null value. Violation of UNIQUE KEY constraint ‘AK_UserName’. Cannot insert duplicate key in object ‘dbo.users’. The duplicate key […]

Loading Multiple Tables using SSIS keeping foreign key relationships

I am trying to load data from a single file (with million+ records) into multiple tables on SQL Server using SSIS while maintaining the relationships defined in the file. To better elaborate with an example, lets assume I am trying to load a file containing employee name, the offices they have occupied in the past […]

isolating a sub-string in a string before a symbol in SQL Server 2008

i am trying to extract a substring(everything before a hyphen, in this case) from a string as shown below: Net Operating Loss – 2007 Capital Loss – 1991 Foreign Tax Credit – 1997 and want the year and name(substring before hyphen) separately, using SQL server Management studio 2008. Any advice? or idea how i can […]

using GO keyword in SQL Server

i know the use of GO keyword. it sends multiple statements to sql server as a whole group, instead of sending each statement one by one. i hope i am right! but i want to know that do programmers use it in real applications. like if we create a stored procedure, then that also does […]

How to multiply a single row with a number from column in sql

In my case there are orders and order positions. Each order position has a quantity. For example: But now I need a single row for each “position element”. This is the output I want: My idea is to use rank() / over() to get the incremental number, but I don’t know how to use the […]

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