My company is working on a development project using SQL Server 2008 Express. The amount of data we plan to store in our main table will quickly exceed the 4GB size limit of Express. We can buy ourselves some time with SQL Server 2008 R2, but eventually we will surpass the 10GB limitation as well.
The team lead wants to hear all availab...
HERE IS THE FUNCTION:
ALTER FUNCTION dbo.FN_GET_QUARTER
-- the parameters for the function here
(
@FN_Qtr_date datetime
)
RETURNS INT
AS
BEGIN
RETURN datepart(qq,@FN_Qtr_date)
END
HERE IS THE SQL REPORT:
IF(SELECT(OBJECT_ID('TEMPDB..#T1'))) IS NOT NULL DROP TABLE #T1
SELECT L_NUMBER, LAST_MAINTENANCE_DATE,
...
I have a complex expression calculating a value from a date that I have to use on multiple date columns.
Can I define a temporary local function in my query to avoid copy and pasting this expression. ?
like:
create MyLocalFunc(@ADate datetime)
returns int as
begin
blablabla
end
select
MyLocalFunc(col1), col2, MyLocalFunc(col3), c...
I am writing a SQL Stored Proc which takes in a single table valued parameter. Is it possible for me to create the table type in the parameter definition, for example:
CREATE PROCEDURE example (
@param (CREATE TYPE tableparameter ( column1 int, colunn2 varchar.... )) READONLY
)
...
I have the following query. What is strange is that it is returning multiple records for the same individual - but it should be returning just one row for each individual. It is all LEFT JOINS based on CONTACT1 C - which has only one row for each individual, unlike the other columns which sometimes have multiple rows for the same individ...
I am trying to total by account, the expenses & income per account. There are multiples of both the income & the expenses per account. I am struggling with this as am still learning SQL and thought that someone else likely has already addressed this? I sure would appreciate the help!
I know that this SQL server code is not correct bu...
We have some data in the SQL server table that needs to scramble. Some data are string and some data are date.
What is best way to do this?
...
Hello everyone,
I want to create a SQL Server 2008 database, and I need to create the database on a network shared location, like \\10.10.10.123\share, but this network shared location is protected by a username and password.
My question is, how to assign such username and password in SQL Server create database statement?
BTW: I have ...
i have around 1000 of rows in database which i want to divide in column group wise. i mean in following format
SlNo. Name Price SlNo. Name Price SlNo. Name Price
how i can write query to show data in above format as in rdlc report vs 2008 i am unable to show data in this format. Any help would be appreciate...
Consider, if you will, the following tables:
This may seem like a strange structure, but allow me to explain. The goal of this structure is to create a report listing all people, excluding those on vacation (for simplicity, we'll pretend that the vacation record will only exist if a person is on vacation.)
The reason I have the Vaca...
How do I create a stored procedure that exists in one database but runs the below code against another (any) database?
SET @sql1 = N'INSERT INTO #Tables SELECT'
+ N' t.TABLE_NAME as TableName'
+ N',t.TABLE_SCHEMA as SchemaName'
+ N',(SELECT OBJECTPROPERTY(OBJECT_ID(t.TABLE_SCHEMA + ''.'' + t.TABLE_NAME),''T...
I am writing a T-SQL program over a DB2 database on a LINUX box (DB2/LINUXX8664) using a linked server. I think the DB2 is Version 9.5.3 but not certain. I am receiving an error that I feel is likely a DB2 issue as the syntax checks out okay in T-SQL. This is the code:
IF(SELECT(OBJECT_ID('TEMPDB..#TempFile))) IS NOT NULL DROP TABLE #Te...
I have an input db2 table with two elements: loan_number, debt_to_income; this table's name is #Input_Table. I am trying to run a test the function by running a SQL program against this table. The problem is that the function's element is not being recognized in the SQL program for some reason, maybe I have been looking at to long? I nee...
I want to change the primary key value for one row in a table that has relations with other tables:
For example
Table Person { Id, Name, +50 fields }
Table Address { Id, City, +10 fields }
Table Person2Address { Id, PersonId, AddressId }
I want to change Person.Id and Person2Address.PersonId
I try something like:
BEGIN TRANSACTIO...
Hi! I am trying to create trigger on SQL Server 2008. I want that if i update field in tabele log that the new value update field in another table Doc. This is the code for trigger:
Create TRIGGER dbo.DocSt
ON dbo.log
AFTER UPDATE
IF (SELECT COUNT(*) FROM inserted) > 0
BEGIN
IF (SELECT COUNT(*) FROM deleted) > 0
...
Is it possible to craft an ORDER BY clause to ensure the following criteria for two fields (both of type INT), called child and parent respectively for this example.
parent references child, but can be null.
A parent can have multiple children; a child only one parent.
A child cannot be a parent of itself.
There must exist at least one...
If I have:
<quotes>
<quote>
<name>john</name>
<content>something or other</content>
</quote>
<quote>
<name>mary</name>
<content>random stuff</content>
</quote>
</quotes>
How do I get a list of the element names 'name' and 'content' using T-SQL?
The best I've got so far is:
declare @xml xml
set @xml = ...
sele...
I need to create trigger in SQL Server 2008 that gone insert all values from one row in which some value was changed into Log table!
For example if i have table Employees that have column id, name , password, and i update this table and insert new value for column name, than i need to insert values that was in table Employees after upda...
I have the following tables:
tblPerson:
PersonID | Name
---------------------
1 | John Smith
2 | Jane Doe
3 | David Hoshi
tblLocation:
LocationID | Timestamp | PersonID | X | Y | Z | More Columns...
---------------------------------------------------------------
40 | Jan. 1st | 3 | 0 | 0 | 0 | M...
Hi guys,
I'm facing a problem now. I use ruby and SQLCMD to generate some TSQL scripts. Now I want to check the syntax of the generated script. I use the following SQL:
SET PARSEONLY ON;
SELECT 888
SET PARSEONLY OFF;
I test it in SSMS, when you select these three statements as a whole batch, sql server will give me the result, which ...