sql-server-2005

Setting Up SQL Server Session Database

I notice that the sql to create the SQL server database (InstallPersistSqlState.sql) basically creates the database ASPState. If I wanted to name that different, can I just replace that with my prefered database name? I understand the script, I just wanted to make sure that ASPState didn't have to be the database name. Thanks! ...

TSQL in SQL 2005: Query

Hi there I have 3 tables: Customer, CustomerTypes, CustomerCustomerTypes. CustomerCustomerTypes is basically is a bridge table between the Customer and CustomerTypes. Table structure: Customers: CustomerID CustomerName CustomerTypes: CustomerTypeID CusctomerTypeName CustomerCustomerTypeID CustomerID CustomerTypeID Sample Data: Custo...

Database Maintenance

I am trying to do some basic maintenance on a sql server 2005 database. It's fairly small (10gb in size, 50 tables or so). I am first doing the following on all tables: update statistics [table name] with fullscan followed by reindexing all tables. DBCC REINDEX ([table name], ...) Is this correct? Is the sequence right? Do I ne...

How to insert xml into a node in another xml using XQuery?

Hi all, I have two xml variable say @res, @student in a stored proc in SQL server 2005. @res contains <Subject>English</Subject> <Marks>67</Marks> <Subject>Science</Subject> <Marks>75</Marks> @student contains: <Student> <Name>XYZ</Name> <Roll>15</Roll> <Result /> <Attendance>50</Attendance> </Student> I need to in...

SQL Server 2005 proper index to filter 30,000,000 registers

Hello, I have a problem with a stored procedure of a transactional table, the user have a web form to find transactions by several values. The process is taking too long and I don't know how to set proper index. here is my stored procedure: CREATE PROCEDURE dbo.cg_searchTransactions ( @id_Ent tinyint, @transactionTypeID int = ...

Trouble creating a recordset from a SQL Server 2005 query with PIVOT

Here's the output code from my stored proc: SELECT * FROM ( select q.ccypair, q.vega, t.label from #parallel q LEFT JOIN TPRR_vega_weights t ON q.Tenor = t.Tenor ) a PIVOT ( Sum(Vega) for a.label in ([t1],[t2],[t3],[t4],[t5],[t6],[t7],[t8],[t9],[t10],[t11],[t12],[t13],[t14],[t15],[t16],[t17],[t18]) )p order b...

sqlcmd runs script but script does not affect database

Hey all, So we have a .bat file that runs SQL scripts, e.g. @ECHO --- 03_Case6395_Publication.sql --- >> dbupt.log sqlcmd -U %1 -P %2 -S %3 -d %4 -i 03_Case6395_Publication.sql -k -b >> dbupt.log IF ERRORLEVEL 1 GOTO ErrorTag The script runs and gives no errors, but the script doesn't actually affect the database. In the example abo...

Unable to import data into SQL Server from Progress DB, issue with data type conversion?

I'm trying to import data from a Progress database into a MS SQL 2005 Server database. On SQL Server, I'm right clicking on my schema name and going Tasks > Import Data... and running through the wizard. I have an ODBC Connection to progress setup, no issues there, I also test my queries using ODBC Explorer first to ensure I have no sy...

Is there an easy way to track all changes in a SQL 2005 Database

Hey, I've been tasked with hooking in our product with another third party product. One of the things I need to do is mimic some of the third-party's product functionality when adding new "projects" - which can touch several database tables. Is there any way to add some kind of global hook to a database that would record all changes mad...

Strategies regarding composite indexes and cardinality

Does cardinality play a role in composite indexes? If so, what? I was running a query that was joining on two columns and it used what I thought to be a sup-optimal index, so it's making me rethink how I design indexes... Let's say we had a table that listed all of the Cities in the United States. My first instinct here is to make a cl...

How to get latest record date from column

Hi, I want to return the date and ID for the latest added record in on of our tables. can anyone suggest right query for that plz. We are using sqlServer SELECT [BGArx_ID], [BGArx_PUBLISHED_DATE] FROM TECH_ARTICLES WHERE [BGArx_PUBLISHED_DATE] = ??? ...

How can i use pivot ?

I am trying to use pivot on a table to rotate(Transpose) the table but i m not getting how to do that. I want to know how it actually works. i found many egs but i was not able to understant how those work. Check this, e.g. How tis is working, i just want to transpose my rows into cols and cols into rows Say i have 31 cols for day1 da...

Want an efficient approach to retrieving records from a database when the retrieval is weighted and balanced.

Im working on something incredibly unique..... a property listings website. ;) It displays a list of properties. For each property a teaser image and some caption data is displayed. If the teaser image and caption takes a site visitors interest, they can click on it and get a full property profile. All very standard. The customer wants...

SQL Server 2005 Express successfully installed, but is nowhere to be found!

Hi, I've SQL Server 2008 Express installed. I've just download and installed SQL Server 2005 Express, but I changed the name of instance into SQLEXPRESS2005 (I added 2005 at the end to avoid conflicting names). Unfortunately, when I try to access the 2005 instance either using the SQL Server Management Studio or the VWD 2008 Express (...

Need help with a SQL query.

SELECT @Tax = SUM(QuoteItem.SalesPrice) * TOP (1) Tax.Amount FROM Tax INNER JOIN Job ON Tax.TaxId = Job.TaxId INNER JOIN Quote ON Job.JobId = Quote.JobId INNER JOIN QuoteItem INNER JOIN Room ON QuoteItem.RoomId = Room.RoomId ON Quote.QuoteId = Room.QuoteId WHERE (Room.QuoteId = @QuoteId) AND (QuoteItem.UnitId = @...

Getting a boolean from a date compare in t-sql select

I am wondering if something along the lines of the following is possible in ms-sql (2005) SELECT (expiry < getdate()) AS Expired FROM MyTable WHERE (ID = 1) I basically want to evaluate the date compare to a boolean, is that possible in the select part of the statement? ...

sql server 2005:how to connect to sql server 2005 on platform jboss 3.0?

i have deployed my application on jboss 3.I have restored a database back up of sql server 2000 on sql server 2005.then i have downloaded the jr file jdbc connection to sql server 2005.My connection string setting is as below. <datasources> <local-tx-datasource> <jndi-name>SLBDataSource</jndi-name> <connection-url>jdbc:sqlserver:...

complete sync between iphone sqlite3 database to sql server 2005 database on the server

Hi, I hava a sqlite3 database placed in the documents folder. I need to sync this database with the sql server 2005, which is running at our server. Is there a possibility that i can do a Replication between a sqlite3 database and a MSSql server 2005. -- Regards, Syed Yusuf ...

Computed columns: SQL or Locally in Entity Framework?

Hello! I have some computed-columns of two types: Computed columns based on columns in current table (i.e. Price * Tax) Computed columns based on other columnes (i.e. Price * fn_GetTax(OrderId)) Would you say it's better to use these columns in CLR on the client only and then save from the server the calculation and transferring per...

how to delete all rows from all tables in a SQL Server database

delete all rows from all tables in a SQL Server database ...