sql-server

SQL Server database compare and sync tool (Free)

Looking for a free and best tool to compare and sync two SQL Server databases. I've searched in stackoverflow for the compare tools but most of them are buy only. Basically this tool will be used for non-commercial use and for developer only. Can anybody suggest tool used by them and it is free? ...

Sql Server Most efficient way to join

I have a table with approx 3000 records which I need to export to csv (through a .net Web application) however I also need to pull information from about 10 other tables (also about 3000 records each) so that the form more columns, e.g. Individual Table Organisation Table IndividualOrganisation Table Output: Individual.Name, Orga...

SPID of a SqlConnection (SQL-Server) in ADO.NET

Can I get a SPID from a SqlConnection Object (SQL-Server Database) in ADO.NET? Is the SPID always the same for a connection object during its lifetime ? ...

SQL Server Number of records affected by an update before executing the actual update

Hey Is there a way to get the number of records by an update-statement before executing the actual update? I know you can just create a select count(1) statement, but my process needs something more generic. ...

SQL Database Publishing Wizard: Is it possible to suppress the comment lines in the generated script?

I use the Database Publishing Wizard in Visual Studio to create a script of a test database (schema and data): The wizard creates a file that I store in my source control system. When I make a few changes to the database I want to publish again in order to save the changes in the source control system. The problem for me is that the wiz...

Crosstab Query in SQL Server 2000

I am hoping that someone has attempted this before and I can get some advice before I go any further. I am looking to produce something similar to a crosstab query in sql-server 2000. I have a table structure similar to the following: Item Item_Parameter Parameter id item_id id desc parameter_id ...

SQL Server Unique Identitifier vs Integer

Hi all, I've been learning ASP.net, and been using the membership system. When it auto generated the tables, I was quite suprised to see it uses a field type called 'uniqueIdentifier' as a primary key, when for many years I have been using an integer field set to be an identity that auto increments. What is the difference (if any at a...

SQL Server 2008: Backing up database before running stored procedure

I have a stored procedure that runs once a week that's initiated by the user through the click of a button on our internal website. I'd like to automatically backup the database before the code in the procedure actually runs. So I've created a separate stored procedure with the following code: DECLARE @Path varchar(50) SET @Path = '\\1...

Running Stored Procedures on a Report Services Model.

Hi I am designing an SQL Report Server Model, to replace a table that was used as a cut down version of the main database to report from. So the report will use the model to report from not the cut down database. I was wondering if there was quick and easy way to take the Stored procedures, that were used for 100+ report on the cut do...

Updating Aggregate Column In Isolation Question

I have a deal and transaction table, where the deal table has an aggregated column, 'TotalSales', which is simply a count of transactions per deal. With the following command, is there ever a chance the transaction row count and total sales count would not be in sync (not including deleting rows)? Does the default isolation level work f...

SSIS MYSQL to SQL Datatype

I'm trying to copy data from MySQL to SQL Server 2008. My SSIS is generating error for time (DBTime) column in MySQL database. (cannot convert dbtime to dbtime2) What datatype can i use in SQL server for time? I tired nvarchar, varchar and also tried data conversion task but i get same error. ...

Is there a way to bind a variable type to column data type?

In Oracle PL/SQL, you can always bind your code variables' type to a specific table.column type like this: myVar TABLE.COLUMN%TYPE So, if you change the column's type, you don't have to go over your code to re-define related var types (of course you'd still need to check you are properly using the variable). Is there a similar way to...

SQL Server Report Services Premisson

I am currently looking into developing and designing the Report service system for work. My user does not seem to have access to Report Builder etc. I have given access to the below roles, but all I can seem to do is view report, create new folders and upload. Browser Content Manager My Reports Publisher Report Builder Does anyone k...

how to restore a sql server backup whose file is on another machine?

How is it possible to restore a database in Machine A (where sql server is installed) from the backup file located in Machine B. Is it possible to avoid to copy the bak file to the machine A? ...

What is the fastest way to convert all PK and FK GUID Columns and relationships to int?

I'm currently developing an ASP.NET MVC application with a ton of PK-FK relationships in the database. In the beginning of development, the team I WAS working with voted against my recommendation to use INTs for all PKs... they decided to use GUIDs. Long story long... the team has split ways, and now I have control to change things... ...

T-SQL creating a dynamic where statement?

I know this is not possible, but is there something that would work? Basically I want the where statement to be dynamic, allowing me to pass it any string, which it will be able to search upon. Declare @search varchar(80) set @search = 'RegionID' Select * from TBL_TripDetails Where @search = '1' Thanks for your answers. After reading...

How to synchronize databases in different servers in SQL Server 2008?

I have 2 databases that have the same structure, one on a local machine and one on the company's server. Every determined amount of time, the data from the local DB should be synchronized to the server DB. I have a general idea on how to do this - create a script that somehow "merges" the information that is not on the server DB, then m...

Advice on entering the world of Visual Studio 2010 (vb) and SQL Server

I'm looking for specific and current advice from professional .NET + SQL Server developers on: best way to get up to speed best reference materials or books to use any pitfalls to watch out for I'm starting a new position next week in which I will be developing advanced accounting software (LAN software) using Visual Studio 2010, Vis...

Setting up ASP.NET SQLServer session state in SQL server using a script

Using the ASPNET_REGSQL tool I generate a script using the following: ASPNET_REGSQL.exe -ssadd -sstype c -sqlexportonly c:\addseesion.sql -E -d myDatabase -s myServer In the script that is created there is this comment: -------------------------------------------------- Note: Do not run th...

Convert a string field with pennies into a dollar amount with 2 decimal places in SQL Server.

I have a field in a table as nvarchar(10), which is used to store a value in pennies. For example, $23.50 is stored as "2350". I need to return this value to the program in Money format. How would I do that in the Select statement? ...