I need a help with a complicated select query.I have message table CREATE TABLE Message( MessageId int IDENTITY(1,1) NOT NULL, /*primary key*/ FromProfileId int NOT NULL, /*foreign key to …
Tag: sql-server-2008
SQL Comments on Create Table on SQL Server 2008
I need to create some pretty big tables in SQL Server 2008, while I do have SQL Server Management Studio, I would like to comment the tables and the columns when I create the table. How do I do this? Example of the query I am running: I’ve tried COMMENT’Expiration Date for the Adult CPR’ and COMMENT=’Expiration Date for the
SQL Server: Why do use SMO?
I have been working with SQL Server for a couple of years. I have heard about SMO but I don’t know anything about it. What are the benefits of using it? Should I learn and start using SMO in my SQL …
SQL Server SELECT LAST N Rows
This is a known question but the best solution I’ve found is something like: SELECT TOP N * FROM MyTable ORDER BY Id DESC I’ve a table with lots of rows. It is not a posibility to use that query …
SQL WHERE clause matching values with trailing spaces
In SQL Server 2008 I have a table called Zone with a column ZoneReference varchar(50) not null as the primary key. If I run the following query: select ‘”‘ + ZoneReference + ‘”‘ as …
Does SQL Server 2008 Service Pack 2 Apply to SQL Server 2008 R2?
I’ve been using SQL Server 2008 R2 for my development. I noticed that service pack 2 for SQL Server 2008 just came out. However, I checked here and Microsoft does not provide a link to any of the service packs for SQL Server 2008 R2. So it is not clear to me whether or not I should apply their service
How to count one to many relationships
ReporterTbl has a one to many relationship with AttachmentTbl. In ReporterTbl, I have an ID (101) and I can have AttachmentTbl more than one Attachments related with ReporterTbl.Id Basically, what I am trying to know is given ReporterTbl.ID, how many Attachments do I have? Table structure: Answer Note: It is important that we are using count(a.id), and not count(*). This
named pipe problem using php to connect ot ms sql 2008
I’m am getting a named pipes error when I try to connect to ms sql server 2008 using a php script running an sqlsrv_connect command. In the ms sql configuration stuff tcp/ip, shared memory, and named pipes are all enabled. Everything is stored on the same server, the database, and the php script so I’m just using a “(local)” for
How to use a value from one stored procedure in another?
I have the following statement in a stored procedure: DECLARE @Count INT EXEC @Count = GetItemCount 123 SELECT @Count Which calls another stored procedure with the following statement inside: SELECT …
Keep local MS SQL 2008 DB table and remote SQL Azure DB table in sync
I have a dedicated server which hosts a Windows Service which does a lot of very heavy load stuff and populates a number of SQL Server database tables. However, of all the database tables it populates and works with, I want only one to be synchronised with a remote SQL Azure DB table. This is because this table holds what