sql-server

SQL Syntax: Create a single table with column names created from data stored over multiple tables

I have created the SQL script below that creates four tables and inserts data into the tables to demonstrate my question (I hope this helps!). This problem arose because originally this data was stored in a single table of 400 columns and it got very unmanageable so I wanted to find a better way to store the parameters: use master G...

Classic ASP - using one connection for many queries?

Consider a classic ASP site running on IIS6 with a dedicated SQL Server 2008 backend... Scenario 1: Open Connection Do 15 queries, updates etc all through the ASP-page Close Connection Scenario 2: For each query, update etc, open and close the connection With connection pooling, my money would be on scenario 2 being the most effec...

How to trasform a microsoft sql server report service in web application

How can i trasform a microsoft sql server report service in web application or something that i can access on the net? thanks to all that would help me ...

non-replicated column still trigger replication

I have a few columns in a table that are added to my publication articles. When a change on a column that is not included in replication occurs, it still seems to update the msrepl_tran_version which i assume still assigns the row for replication. Is this how SQL-Server works? Is there a way to tell sql only to relicate rows when a colu...

SQL Server: Design: Embedded Select statement or INNER JOIN ?

I've the following table structure - Site: Master tablefor site Org: Master table for Org User: Master table for User (each user links to a unique Org via User.OrgId) OrgSite: Store some 'Org specific' Site details (OrgId, SiteId, SiteName, SiteCode). Not ALL sites but only those which are accessible to Org. ...

Split the output rows in groups in SQL Server

I have to divide the rows equally, so here, for example, there are 15 rows. I want to divide equally, which is in three groups, but I want the name to come only in front of the first entry of each group, as shown: DECLARE @NAMES TABLE ( [ID] INT IDENTITY, [NAME] VARCHAR(20) ) INSERT INTO @NAMES SELECT 'NAME1' UNION ALL SELECT 'NAME2' ...

CHAR behavior with trailing spaces.

Given the SQL statements below, I would expect the result of the query to be: |testX|5| |XXXXX|5| This is because the column is a char(5) and I would expect it to insert blank trailing spaces to fill the remaining space in the column since the inserted values are less than five characters. However, the query actually produces the fol...

SSMA timestamp. What's it for, how is it used?

I rencently used the SQL Server Migration Assistant to import a database into SQL Server 2005. I noticed that a number of tables that were imported have been ammended with a new column called SSMA_timestamp. Can anyone tell me what this is for and how it would be used? ...

Insert image to reporting project into iif

I would like to insert an image into this expession instead of True and False =IIf(Sum(Fields!cont.Value, "DataSet7")<>Sum(Fields!tot.Value, "DataSet7"), True,False) i would like to insert a red or green image to compare this two fields thanks to all who wants to help me ...

Sql server 2005 on sql server 2000

I want to ask is there any issues or risks involved in installation of SQL Server 2005 Enterprise Edition on SQL Server 2000 Enterprise Edition in production server? Please tell me the guidelines in installation... ...

Architecture question - call a remote SQL Server directly or thru a service?

In my new WPF/silverlight app, is it better to directly connect to my remote SQL Server (I'm using linq to sql), or is it better to call a WCF service and have the service connect to the database? The SQL Server and a Win2k8 web server are both leased and at the same location. If creating a WCF service, I would run it on the web serve...

Crystal Reports with SQL Server 2005: Setting Transaction Isolation Level

Is there a way to specify the transaction isolation level when Crystal Reports queries a SQL Server 2005 database without resorting to any of the following: Encapsulating the report's query in a stored procedure that executes SET TRANSACTION ISOLATION LEVEL... before the query itself Hand-writing the SQL query in Crystal Reports to exe...

Should a Sequential Guid primary key column be a clustered index?

The goal of using a sequential guid is so you can use clustered indexes without the high levels of fragmentation that would normally exist in a clustered index if it was a regular guid, correct? ...

Simplest way to do a recursive self-join in SQL Server?

What is the simplest way of doing a recursive self-join in SQL Server? I have a table like this: PersonID | Initials | ParentID 1 CJ NULL 2 EB 1 3 MB 1 4 SW 2 5 YT NULL 6 IS 5 And I want to be able to get the records only related to a...

Any overhead using SQL Linked Servers between databases on the same server?

We're looking to iron out issues in our different dev/test/prod environments. Currently we have to remember to change the name of linked servers in stored procedures when we migrate from UAT into Production. For example, in Production, a sproc in SMOLDB calls across a linked server to LS_AUTH.AuthenticationDB.dbo.SomeSproc because Aut...

Pagination in SQL Server

How do i limit the result of a query (in my case about 60K rows) and select only from the X row to the Y row? If I use ROW_NUMBER() I don't like my query because it involves 2 select queries .. one to return the rows and one to select the portion I need Update: Here's the query I use now: SELECT * FROM ( SELECT row_numb...

C# - MySQL vs SQL Server

Hello, For the longest time, I've been using MySQL servers to handle data (in JAVA, and in C#). But lately, I've been hearing good things about LINQ and SQL Server. I've been thinking of converting, but I don't know much about the SQL Server. Could anyone who has used SQL Server before, please define how well it is compared to MySQL se...

Unable to use fully qualified table name in dynamic SQL

I'm trying to update a table on several remote servers by iterating over a list of server names and executing some dynamic SQL. See below. DECLARE @Sql NVARCHAR(4000) DECLARE @Server_Name VARCHAR(25) SET @Server_Name='SomeServer' SET @Sql='UPDATE ' + @Server_Name + '.dba_sandbox.dbo.SomeTable SET SomeCol=''data''' PRINT @Sql EXEC @Sql ...

Fully qualified table names with SP_ExecuteSql to access remote server

Trying to update a table on a linked server (SQL 2000/2005) but my server name will not be known ahead of time. I'm trying this: DECLARE @Sql NVARCHAR(4000) DECLARE @ParamDef NVARCHAR(4000) DECLARE @SERVER_NAME VARCHAR(35) SET @Sql = 'UPDATE @server_name_param.dba_sandbox.dbo.SomeTable SET SomeCol=''data''' SET @ParamDef = N'@server_n...

How to copy large set of data in SQLServer db

I have a requirement to take a "snapshot" of a current database and clone it into the same database, with new Primary Keys. The schema in question consists of about 10 tables, but a few of the tables will potentially contain hundreds of thousands to 1 million records that need to be duplicated. What are my options here? I'm afraid tha...