How can I find all column values in a column which have trailing spaces? For leading spaces it would simply be
select col from table where substring(col,1,1) = ' ';
I have two databases that are mirrored to another server using database mirroring. The mirror server has to be down for some reason for few days. Now the production server is having principal databases in (PRINCIPAL/DISCONNECTED) State. Clients can access those databases. So what happens when they keep on adding data to these databases?? Will the…
Hi, I am in the process of trying to configure SQL Server 2008 to accept remote connections. I have been through all the documentation I can find and yet when I attempt to connect through management studio I get an error stating that the server could not be found.
Interestingly I can connect through telnet to the remote server via the port that…
Recently we have moved our sharepoint 2007 db from sql 2000 server to 2008 x64 SQL server.
All seems well, however there is a problem where the sql server stops running and the service has to be restarted.
The errors mention insufficient internal memory etc.
I have tried to start the db using -g384 which is the default in sql 2000 but 256 is…
I have table to test score data that I need to pivot and I am stuck on how to do it.
I have the data as this:
gradelistening speaking reading writing
0 0.0 0.0 0.0 0.0
1 399.4 423.8 0.0 0.0
2 461.6 508.4 424.2 431.5
3 501.0 525.9 492.8 491.3
4 521.9 517.4 488.7 486.7
5 555.1 581.1 547.2 538.2
6 562.7 545.5 498.2 530.2
7 560.5…
Here is my scenario, I'm creating a dynamic query using a select statement which uses functions to generate the query. I am storing it into a variable and running it using exec. i.e.
declare @dsql nvarchar(max)
set @dsql = ''
select @dsql = @dsql + dbo.getDynmicQuery(column1, column2)
from Table1
exec(@dsql)
Now it produces the many…
Hello,
I want to construct a SELECT statement with a conditional IF.
Like, IF there is no records with the language code 'Swedish':
SELECT * FROM Entries WHERE Language = 'Swedish'
THEN use 'English'
SELECT * FROM Entries WHERE Language = 'English'
How would I construct this statement using MSSQL?
Thanks,
Stefan
I have VS 2008 Professional Edition. After the installation (which included SQL Server 2008), I decided to install SQL Server 2008 Express Edition with Advanced Tools (so I could get SQL Server Management Studio on it). So I uninstalled the SQL Express that came with VS 2008, and installed the standalone SQL Server Express 2008 version…
Hi ,
I have a dataset with some 30 records in it. I want to update it to the database tables. which is the best method to update the table.
I am unable to use dataadapter.update() since i am using a procedure to populate the dataset.
is there any efficient way to update other than iterating through EACH…
Hi Guys,
i tried to open the website from broswer project is deployed at IIS i am getting this exception
Exception information:
Exception type: SqlException
Exception message: Cannot open database "TestDB" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
any solution?
…
I am trying to retrieve some records from table based on my query but it shows me an error
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '
select vd.LedgerId,(CreditAmt-DebitAmt) AS NET, CASE NET
WHEN NET > 0 THEN 'Debit' WHEN NET < 0 THEN 'Credit' ELSE 'Nil'End
from dbo.vdebit vd INNER JOIN…
I have a query that searches for clients using "like" with wildcard. For example:
SELECT TOP (10) [t0].[CLIENTNUMBER], [t0].[FIRSTNAME], [t0].[LASTNAME], [t0].[MI], [t0].[MDOCNUMBER]
FROM [dbo].[CLIENT] AS [t0]
WHERE (LTRIM(RTRIM([t0].[DOCREVNO])) = '0') AND ([t0].[FIRSTNAME] LIKE '%John%') AND ([t0].[LASTNAME] LIKE…
I have a query that searches for clients using "like" with wildcard. For example:
SELECT TOP (10)
[t0].[CLIENTNUMBER],
[t0].[FIRSTNAME],
[t0].[LASTNAME],
[t0].[MI],
[t0].[MDOCNUMBER]
FROM [dbo].[CLIENT] AS [t0]
WHERE (LTRIM(RTRIM([t0].[DOCREVNO])) = '0')
AND…
Hi there,
Suposse you have to following tables where a sale consists of products and a product can be placed in multiple categories. Whereby categories have a hierachly structure like:
Man
Shoes
Sport
Casual
Watches
Women
Shoes
Sport
Casual
Watches
Tables:
Sale:
id name
1 Sale1
…
So I was requested to make a few things.... (it is Monday morning and for some reason this whole thing is turning out to be really hard for me to explain so I am just going to try and post a lot of my code; sorry)
First, I needed a table:
CREATE TABLE TICKET_INFORMATION (
TICKET_INFO_ID INT…
With reference to my previous question
Adding columns resulting from GROUP BY clause
SELECT AcctId,Date,
Sum(CASE
WHEN DC = 'C' THEN TrnAmt
ELSE 0
END) AS C,
Sum(CASE
WHEN DC = 'D' THEN TrnAmt
ELSE 0
END) AS D
FROM Table1 where AcctId =…
SELECT name FROM sys.databases -- this can list all database name in the server
user database
SELECT * FROM INFORMATION_SCHEMA.TABLES -- these two line can list the table for one particular database
but how to do something in order can have the result like the following
Database …
Hello,
I execute a select to get the structure of a table.
I want to get info about the columns like its name or if it's null or if it's primary key..
I do something like this
....sys.columns c...
c.precision,
c.scale,
c.is_nullable as isnullable,
c.default_object_id as columndefault,…
I have the following script which I use to give me a simple "diff" between tables on two different databases. (Note: In reality my comparison is on a lot more than just an ID)
SELECT
MyTableA.MyId,
MyTableB.MyId
FROM
MyDataBaseA..MyTable MyTableA
FULL OUTER JOIN
…
For some unknown reason I'm running into a problem when passing a variable to a full text search stored procedure performs many times slower than executing the same statement with a constant value. Any idea why and how can that be avoided?
This executes very fast:
SELECT *…
In my database, assume we have a table defined as follows:
CREATE TABLE [Chemical](
[ChemicalId] int NOT NULL IDENTITY(1,1) PRIMARY KEY,
[Name] nvarchar(max) NOT NULL,
[Description] nvarchar(max) NULL
)
The value for Name can be very large, so we must use…