Need Help Creating Query

Jul 23, 2005

I am working with employee schedules. Each schedule is comprised of
segments (shift, lunch, break, training, etc.) that have rankings.
Each record has the employee id, the date the shift starts, the start
and end time of each segment, the duration,the segment type and its
rank. The start and end times of the schedules can overlap, but the
segment that has the higher rank takes precedence.

As a simple example, an employee working 8a-5p will have two records.
The shift segment from 8a-5p and a lunch segment from 12p-1p. The
lunch ranks higher so, even though the shift goes from 8a-5p, from
12p-1p, the lunch takes precedence.

What I'm trying to do is build a query that will collapse the segments.
So given the example above, I will now have three records: shift
8a-12p, lunch 12p-1p, shift 1p-5p.

I have been racking my brain but I just can't figure it out.
Ultimately, a programmer in my office will display this in a bar chart
format with each segment type having its own color. I'm trying to do as
much of the work in SQL so he doesn't have to calculate this stuff in
the code.

Any help would be appreciated.

Thanks.
Angela

View 5 Replies


ADVERTISEMENT

Creating A Query In ASp.NET SQL

May 18, 2008

Hi, i have been able to create a query in asp.net in the sever explorer.
I want to create an statement as a new column.
In Access i would do it like this (Agg: [Scored]-[Against])
But how do i call a new column Agg in SQL and then tell it to take Against away from Scored?

View 3 Replies View Related

Help Creating Query

Apr 1, 2008

SELECT Name, TagID,
(SELECT COUNT(TagID) AS Expr1
FROM dbo.mw_PagesTagMap
WHERE (TagID = tag.TagID)) AS TagWeight
FROM dbo.mw_Tags AS tag




This query works exactly how I want it to.
I would like to modify this to NOT return any column that has a TagWeight of 0

SELECT Name, TagID,
(SELECT COUNT(TagID) AS Expr1
FROM dbo.mw_PagesTagMap
WHERE (TagID = tag.TagID)) AS TagWeight
FROM dbo.mw_Tags AS tag
WHERE (TagWeight <> 0)
I thought this would do it but I'm getting an error "invalied column TagWeight".
How would I get this to work?

View 3 Replies View Related

Need Help Creating A Query..

Apr 15, 2008

Hey all, am a bit new to SQL so excuse my ignorance I am wanting to create a query that uses 2 parameters and returns 20 random records that meet the criteria.
One of the parameters is stored in a different table to the one im querying, and the other is a selection made by the user on a VB form.. If its any help, my table schema is:

QUESTION: (QuestionID, Text, Answer, Category, AbilityLevel)

I need AbilityLevel to match a variable stored in the VB form and Category to match a value selected by the user from a combo-box.

I really dont know where to begin with this so any help would be greatly appreciated!

Cheers,
Adam.
P.S. apologies if this is too VB related to belong in this forum!

View 5 Replies View Related

Error In Creating Query

Aug 11, 2000

Hi,

I don't see what's wrong with this command.
>>
Create View BCPOutBatchWeightTaiwan AS
Select *
from batchWeight a JOIN Geography b
ON a.GeographyPtr = b.GeographyPtr
where b.countrycode = 'tw'
<<
I get the following error if I try to create it.
>>
Server: Msg 4506, Level 16, State 1, Procedure BCPOutBatchWeightTaiwan, Line 2
Column names in each view must be unique. Column name 'GeographyPTR' in view 'BCPOutBatchWeightTaiwan' is specified more than once.
<<

But it runs fine if I run only th 'Select' part of the command
without 'CREATE' line.

Any help is appreciated.

Thanks.
Ranjit

View 1 Replies View Related

Creating New Transaction Query

Jun 15, 2007

I have a table with the following columns: Rtype, Amount, Refnumber, Color:
Here is what the table looks like:

RD 25 1 blue
AB 45 2 green
AC 25 3 purple
AD 34 4 blue
AE 25 5 pink

Now lets say I would like to create new transactions for all 'RD' Rtypes, but I would like to change the Amount to lets say, 99 for all of 'RD' types, but keep the same refNumber. For example, I want to create and insert a new transaction for RD, but with the amount 99, so that the row looks like this:

RD 99 1 blue

Where do I put in the query to change the Amount value? I do not wish to use the update function, because I actually want to create a new row. The query I am using, but not working is:

INSERT INTO EMPLOYEES(Rtype, Amount, Refnumber, Color)
SELECT Rtype, Amount, Refnumber, Color
FROM Employees
WHERE Rtype = 'RD';
Reply With Quote

View 1 Replies View Related

Error When Creating DMX Query

Nov 8, 2006

On screen states [Error loading mining model metadata: No Metadata found]

and on the functions states [Error loading functions: no functions found]

This also occures when trying to use the Data mining wizard, it will just not respond.

Have deleted and removed all references to SQL2005 Standard and reloaded and still get same errors

Could someone please advise, have sent errors to Microsoft with no responce back yet.



View 1 Replies View Related

Problem In Creating Query?????

Nov 28, 2007

Hi
i have a table with 2 columns region and Ddate .
I want total records for a particular region.
I am creating query as follows:

SELECT Region, COUNT( * ) FROM Market_data
GROUP BY Ddate

The above query is generating error.
So how can i create the query????????????

View 1 Replies View Related

Creating A Formated SQL Query And Email It

Feb 4, 2002

I need to create a "simple" sql query but have it formatted and then emailed
to individuals. I am trying to convert over from Oracle but I am having a
hard time getting the query to be formatted the way I want. Here is the select statement I tried to use with no luck with xp_sendmail:

SELECT ALARM ID, TIMESTAMP as TIME, CLASS, RESOURCE, P, L, F, ALARM_MESSAGE
FROM ALARM_LOG WHERE ([TIMESTAMP] < GETDATE() - 1) ORDER BY [TIMESTAMP];


Here what the output should look like with the column headers underlined and
then the column data (notice the column heading ALARM MESSAGE is on the
next line before any data):

ALARM ID TIME CLASS RESOURCE P L F
-------------------- ----------- ----- ---------------- - - -
ALARM_MESSAGE
-------------------------------------------------------------
B3_TEMP_ALM 02-02@11:21 ALARM BUILDING3_TEMP N G G
BUILDING 3 TEMPERATURE ALARM, CALL SECURITY.

B5_TEMP_ALM 02-02@11:22 ALARM BUILDING5_TEMP N G G
BUILDING 5 TEMPERATURE ALARM, CALL SECURITY.


How can I run the query and have it formatted and emailed out?
What is the best way to accomplish this?

Thank you,

Mark

View 1 Replies View Related

Creating Table From Query Results

Feb 6, 2014

I have this query;

select c.name
FROM sys.tables AS t
INNER JOIN sys.columns c
ON t.OBJECT_ID = c.OBJECT_ID
where t.name= 'Hosea_tblDATA_NOTES'and c.is_identity = 0
order by column_id

and I get these results;

NOTE_ID
NOTE_DESCRIPTION
NOTE_TEXT
NOTE_STATUS
NOTE_STARTDATE
NOTE_ENDDATE
NOTE_AUTHOR
NOTE_LASTUPDATE

I was thinking if it is possible to create a table from the results of this query, my table name(in this case 'Hosea_tblDATA_NOTES') will be a parameter, that whatever table name I pass, with the results I get I will be able to create another table, assuming all data types are varchars, but it should be generic.

I want to create a new table with the about of that query, that output has to be my columns.

View 1 Replies View Related

Creating A DB To Query Game Server

Mar 3, 2008

Im just wondering if it is possible to use a SQL DB to query game servers, Im very new to SQL, an if it is possible please lead me in the right direction on start this.

Thanks,

View 8 Replies View Related

Creating Expressions With The Query Builder

Sep 18, 2007

Hello,

I have a question about using the query builder, or just straight sql, to create expressions. My first example caused the query builder to generate a query configuration error:


Expression: EIM_REQUISITION_DETAILS.EST_UNIT_COST * EIM_REQUISITION_DETAILS.REQRD_QTY AS COST


Syntax error: Expecting "," or "FROM" after column alias or "*"

Initially I thought I was dead in the water but then I decided to just run it anyway and it worked! I got my cost. OK so fine the query tool doesn't recognize some sql expressions. Because I am trying to make a large flat file I thought I'd concatenate 2 fields to generate a recognizable requisition, which everyone knows is the year followed by a hyphen then the req number:



My old Access query had this: Req: Right([REQ_YR],2) & "-" & [REQ_NO]

and I tried to change it to this: substring (EIM_REQUISITIONS.REQ_YR from 2 for 2) || '-' || EIM_REQUISITIONS.REQ_NO AS REQ

So apparently my older sql book doesn't have the syntax right. Since I plan to do more of this could someone point me to a reliable book or site that could help me with sql syntax?

Thanks,
Dana




View 3 Replies View Related

Creating A Sequential Row Number In A Query Resultset --- Is It Possible?

Feb 17, 2005

Hello everyone,

I have a stored procedure that supplies rows for a front-end DataGrid that allows custom paging. The stored procedure must return the requested "page" of rows as identified by a sproc argument. Currently, I'm loading the the query's result set into a temporary table that has an identity column as primary key. I then run a second query against the temp table that uses the identity column value to strip out the requested "page" of rows and return them to the front-end DataGrid.

I'd like to eliminate the temporary table. To do so I would need to create the equivalent of an identity column in the query's sorted results and reference this value in the WHERE clause in order to return only the requested rows.

Does anyone know of a way to generate a sequential number (starting at 1) within a query (and after the rows have been sorted by the ORDER BY)? I don't think this can be done but I put it out for those who may know better.

Thanks for your help. If you know this is impossible, that would be helpful feedback as well.

BlackCatBone

View 3 Replies View Related

Creating A Query Showing File Not Existing

Jan 16, 2008

This is a SQL question while using Microsoft SMS.

I am trying to write a SQL query looking for a specific file in a specific directory. If the File does not exist, then I want it to display.

here is the Code that I have for it that shows that the file exists... how do I make it show that the file doesn't exist?... what am I doing wrong?

Thanks for all your help in advance!

**********************************

SELECT TOP 100 PERCENT SYS.Netbios_Name0, SYS.User_Name0, SF.FileName, SF.FileVersion, SF.FileSize, SF.FileModifiedDate, SF.FilePath,
SYS.Operating_System_Name_and0
FROM dbo.v_GS_SoftwareFile SF INNER JOIN
dbo.v_R_System SYS ON SYS.ResourceID = SF.ResourceID
WHERE (SF.FileName = 'UdaterUI.exe')
AND (SF.FilePath = 'C:Program FilesMcAfeeCommon Framework')
OR
(SF.FileName = 'UdaterUI.exe')
AND (SF.FilePath = 'c:Program FilesNetwork AssociatesCommon Framework')
ORDER BY SF.FileVersion, SYS.Netbios_Name0

View 1 Replies View Related

SQL Server 2012 :: Creating XML File From Query?

Apr 15, 2015

What I am trying to recreate is:

<value version="5" type="database">
<name>master</name>
<server>servername</server>
<integratedSecurity>True</integratedSecurity>
<connectionTimeout>15</connectionTimeout>

[Code] ....

with this query:

SELECT
'version="5" type="database"' AS 'value',
'master' AS 'name',
LTRIM(RTRIM(([Server Name]))) AS 'server',
'True' AS 'integratedSecurity',

[Code] ....

BUt my output is not correct, it is creating this:

<value>
<value>version="5" type="database"</value>
<name>master</name>
<server>ServerName</server>
<integratedSecurity>True</integratedSecurity>

[Code] .....

So my question is how to I get <value>version="5" type="database"</value> as the first 'value' node?

I've tried multiple ways, but no success.

View 2 Replies View Related

T-SQL (SS2K8) :: Creating Range Between Values In Query?

Apr 26, 2015

On a new project i need to create possible ranges between a specific interval.

suppose i have this main product:

main product : LY E67F

Also, in first level i have a table classify by Group depending on Intensity.

table group
Group intensity
AA 1120
AB 1400
BA 1800
BB 2240
CA 2800

I need to create these diferent options:

1 option : AAAB or AABA or AABB or AACA
2 option : ABBA or ABBB or ABCA
3 option : BABB or BACA or BBCA
or beginning from the end
1.option CABB or CABA...
or beginning from the middle
1.option BBBA or BBAB
and so on.

I fact, i need to find all available options possibles to build article code, like a matrix.

View 7 Replies View Related

Creating SELECT Query Which Involves Getting FIRST Occurrence

Apr 25, 2014

I have a problem creating a SELECT query which involves getting the FIRST occurrence, the SUMS and the LAST occurrence of a selected row. I have two tables A and B which has the following data:

Table A

----------------------------------------------------------------
|Item ID | Item Name | Item Description | Current Quantity |
----------------------------------------------------------------
----1------------Bolts-------------35"----------------20
----2-----------Paint----------GOLD Paint------------30
----3-----------Screws------------30"----------------40
----------------------------------------------------------------

and Table B

--------------------------------------------------------------
|Log ID | Item ID | Beginning | Add | Less | Ending | Date |
--------------------------------------------------------------
---1---------1----------30-------0-----10------20------04-04
---2---------2----------40-------10----10------40------04-04
---3---------3----------50-------5-----10------45------04-04
---4---------1----------20-------0-----0-------20------04-05
---5---------2----------40-------0-----10------30------04-04
---6---------3----------45-------0-----5-------40------04-04
-------------------------------------------------------------

and I have two datetime pickers, one FROM date picker and a TO date picker If a user selects FROM 04-04 TO 04-05...I want a select statement which will select the Item Name and Desc, the BEGINNING QUANTITY (in reference to the FROM DATE), the SUM of Adds and Less and the ENDING QUANTITY (in reference to the To Date) and then group by their Item ID

In this case, it will generate a table like this

----------------------------------------------------------
Item Name | Item Desc | Beginning | Add | Less | Ending |
-----------------------------------------------------------
--Bolts---------35"---------30---------0-----10-----20
--Paint-----Gold Paint------40---------10----20-----30
--Screws-------30"---------50---------5-----15-----40

"SELECT A.Item Name, A,Item Desc, B.Beginning=(select B.Beginning from Table B where A.Item ID = B.Item ID AND Date = From Date), SUM(B.ADD), SUM(B.LESS), B.Ending=(select B.Ending from Table B where A.Item ID = B.Item ID and Date = To Date) WHERE A.Item ID = B.Item ID and Date(B.Date)>From Date AND Date(B.Date)< To Date group by B.Item ID order by A.Item Name, Item Desc"

My query returns the right Item Name, Desc, the Sum of Add and Less.My problem is that I can't get the value of my beginning and ending.I think I have a problem in A.Item ID = B.Item ID. As I tried a fixed value condition, (B.Item ID = 2), it will get the right result), I'm guessing the program is not getting A.Item ID.

View 1 Replies View Related

Creating Table From Query Analyzer Gives Error

Oct 25, 2005

Hi,

I have the TAMCreate.sql file which contains the script to create all tables in the Database TAMaintenance. Its created and used in the SqlServer 2000. But i have only SqlServer 7. From the script i copy and paste each table and created upto 7 tables without any problem, when i create the 8th table i get the following error the code for the table

CREATE TABLE AA_Branch_Master(
Branch_Code varchar(15) CONSTRAINT PK_AA_Branch_Master1 PRIMARY KEY,
Branch_Name varchar(50) NOT NULL,
Branch_Opened datetime NOT NULL,
Branch_Location varchar(50) NOT NULL,
Branch_Province varchar(25) NOT NULL,
Branch_Incharge varchar(50) NOT NULL,
Branch_Remark varchar(150),
Branch_Status BIT(1))
go

Error:
Server: Msg 2716, Level 16, State 1, Line 1
Column or parameter #8: Cannot specify a column width on data type bit.

In the same way i have get the error or another table, rest of the tables are created successfully.

the code for the table

CREATE TABLE AA_Supplier_Master(
Supp_Code varchar(15) CONSTRAINT PK_AA_Supplier_Master1 PRIMARY KEY,
Supp_Name varchar(100) NOT NULL,
Supp_Address varchar(150) NOT NULL,
Supp_Contact_Person varchar(50) NOT NULL,
Supp_Paymode varchar(25) NOT NULL,
Supp_Tel1 varchar(25),
Supp_Tel2 varchar(25),
Supp_Fax varchar(25),
Supp_Postbox varchar(15),
Supp_Postal_Code varchar(15),
Supp_City varchar(50) NOT NULL,
Supp_Country varchar(50) NOT NULL,
Supp_Status BIT(1))
go

Error:
Server: Msg 2716, Level 16, State 1, Line 1
Column or parameter #13: Cannot specify a column width on data type bit.

Thankyou,
Chock.

Chock

View 1 Replies View Related

Creating A Query That Access Multiply Databases

Dec 10, 2007


Dear Readers,
Is it possible to create a query that access multiple sql express databases? Or is it possible to link a table in one database from another?

View 1 Replies View Related

Creating A View Form A Sequel Query

Apr 18, 2008

I've written a Union query that joins 16 different tables. I need to somehow make this into a permanent view so that i can query directly from excel to extract specific data - i guess i can set up excel to pull straight from this view then ?

I'm used to running excel VB code to SQL via Access (linking access up) but want to cut out the middleman now.

Any ideas ?

An example of the Union Query i have built is below :


SELECT[Vendor No_],[Posting Date],[Purchase (LCY)],[Buy-from Vendor No_],[External Document No_],[IC Partner Code]

FROM [NAV402].[dbo].[TESTCO Sweden$Vendor Ledger Entry]

WHERE[Posting Date]>='20070701' AND [Vendor No_] LIKE 'ZX%'

UNION

SELECT[Vendor No_],[Posting Date],[Purchase (LCY)],[Buy-from Vendor No_],[External Document No_],[IC Partner Code]

FROM [NAV402].[dbo].[TESTCO Taiwan$Vendor Ledger Entry]

WHERE[Posting Date]>='20070701' AND [Vendor No_] LIKE 'ZX%'

UNION

SELECT[Vendor No_],[Posting Date],[Purchase (LCY)],[Buy-from Vendor No_],[External Document No_],[IC Partner Code]

FROM [NAV402].[dbo].[TESTCO US$Vendor Ledger Entry]

WHERE[Posting Date]>='20070701' AND [Vendor No_] LIKE 'ZX%';


Thanks for any help you can give me.

PID

View 3 Replies View Related

Creating Tables In SQL Server Via Query Analyzer With Relationships

Jun 7, 2005

I've been searching around for some info on how to set this up, but with no luck.I need to have a .sql file that will set up a few tables and these tables will have relationships and contraints.I can do this by hand in enterprise manager, but need to set up some procedures that will do the same thing.For instance, I can create the tables just fine.....CREATE TABLE students ( sId int NOT NULL PRIMARY KEY,        studentId varchar(50) NOT NULL,               course varchar(50)              )
CREATE TABLE courses  ( cId int NOT NULL PRIMARY KEY,        course varchar(50) NOT NULL,               sco varchar(50)              )But, I need to set up relationships in there somehow.Once student may have many courses (one to many) and one course may have many sco's (one to many) SCO would be another table.Can someone point me to a good link that would show how to complete these procedures?Thanks all,Zath

View 4 Replies View Related

Creating Query To Update A Field For Multiple Items

May 5, 2015

Looking to write an query that will update a field for multiple items, like 1,500.

something like:

UPDATE INMAST
SET FPRICE = 111.11

WHERE
INMAST.FPARTNO = 'xxx'

only issue I'm having is a need to do a JOIN because there's one more condition that must be met from another table, i've tried this:

SET FPRICE = 111.11
JOIN INVCUR
ON
(inmast.fpartno + inmast.frev)= (invcur.fcpartno + invcur.fcpartrev)

WHERE
INMAST.FPARTNO = 'NRE'
AND
invcur.flanycur = 'TRUE'

but that is giving me an error around the JOIN

View 11 Replies View Related

SQL Query - Updating Selected Rows/Creating New Row - Same Table

Jan 24, 2008

I have to write a couple scripts that will update a couple columns in two separate tables and also insert a new row with the same data except for a few calculated or provided values ...... see specs below ...




1. tGradeHist Table Script One (Needs to be run first)



a. Read tGradeHist Table and Select rows with GradeEndDate = NULL and GradeStartDate = '1/1/2007 12:00:00 A.M.'

b. Calculate New Step Amount = StepAmount * Incr% (Round To Nearest Whole Dollar)

c. Create New Row for this table using information from row read above and insert new information where indicated :


GradeCode - Same

GradeLocationCode - Same

Step - Same

GradeStartDate - '7/1/2007 12:00:00 A.M.'

GradeEndDate - NULL

GradeCurrencyCode - Same

StepAmount - Result of b (above)

GradeFrequencyCode - Same

RangeMaximumAmount - Same

RangeMidAmount - Same

RangeMinimumAmount - Same

GradeCurrentFlag - 'True'

MarketMaximumAmount - Same

MarketMidAmount - Same

MarketMinimumAmount - Same

GradeGUID - Same

TSCOL - Same


d. Update Row read in a (above) with GradeEndDate = '6/30/2007 12:00:00 A.M.' and GradeCurrentFlag = 'False'





2. tPersonBasePayHist Table Script Two (Needs to be run second)


a. Read tPersonBasePayHist Table and Select rows with PersonBasePayEndDate = NULL

b. Calculate New PersonBasePayAmount = PersonBasePayAmount * Incr% (Round To Nearest Whole Dollar)

c. Create New Row for this table using information from row read above and insert new information where indicated :



PersonGUID - Same

PersonBasePayStartDate - '7/1/2007 12:00:00 A.M.'

PersonBasePayEndDate - NULL

PersonBasePayCurrencyCode - Same

PersonBasePayAmount - Result of b (above)

PersonBasePayFrequency - Same

PersonBasePayPayrollFrequencyCode - Same

BasePayReasonCode - 'SA'

ConductedBasePayReviewDate - Same

ScheduledBasePayReviewDate - Same

PayrollCode - Same

PersonBasePayCurrentFlag - 'True'

ApprovedByPersonGUID - Same

PersonBasePayGUID - Same

TSCol - Same



d. Update Row read in a (above) with PersonBasePayEndDate = '6/30/2007 12:00:00 A.M.' and PersonBasePayCurrentFlag = 'False'














View 7 Replies View Related

Ssis Creating A Basic Package Tutorial - Not A Query

Jun 13, 2006

In the tutorial Creating a Basic Package Using a Wizard > Lesson 1: Creating the Basic Package >

says to use the following sql statement on the query page:

SELECT * FROM [Customers$] WHERE NumberCarsOwned > 0

When I paste the query in I get the message :

This SQL statement is not a query.

Does anyone have any suggestions?  The input and output are set up correctly and I have the sample excel file Customers.xls. 

I am new to all this, is there some setting I need to change for the tutorial to work or..?

FYI I have installed Sql 2005, Sp1.

 

View 4 Replies View Related

Transact SQL :: Query To Check Properties On A Table When Creating Database?

May 20, 2015

I'm wondering if there is some sql I can run to check properties on a table. This would be used to verify things like data types, allow nulls and default values have been set to avoid mistakes. This could be done manually one table and one column at a time, but it would be a lot easier to look at it in the results window.

View 5 Replies View Related

Transact SQL :: Creating Report - Query With Parameters Based Off Values

Sep 1, 2015

I have the following report I need to create with 2 parameters. An equal OR not equal. I need the report to have a drop down that has equal to  '1024' or a drop down option that IS NOT equal to '1024'. I also need the WHERE clause to return the equal or not equal based on the user selection inside of SSRS.

SELECT user1 AS [Company], reference AS [PAI_REF], statenumber,
LEFT(user4, 7) AS [Supplier Code],
user4 AS [Company Information], 
user8 AS [Transaction Type], user2 AS[Invoice Number], 
--CONVERT(VARCHAR,CONVERT(Date, user3, 103),101) AS [Invoice Date],
[routeName] AS [Route], username AS [User Name]

[Code] ....

View 2 Replies View Related

Dynamically Creating Excel Worksheets Based On Groupings From Query In SSIS

Apr 24, 2008

Is there anyway to dynamically create Excel Worksheets based on a group identity results from a query?

Thanks!

SkySeek.

View 7 Replies View Related

T-SQL (SS2K8) :: Creating A Query To Show Data Side By Side

Nov 26, 2014

I am working to create a phone list that will contain Last Name, First Name, and Phone Number sorted by last name. For printing purposes I would like to have three columns of data instead of the standard of one column.

Is it possible to create a query to present data in three columns showing the data side by side?

View 9 Replies View Related

Creating Trigger On Creating Table

Jan 28, 2008



Hi,

If I want to automatically insert a record which has default value in a table,
how can I create the trigger?

View 5 Replies View Related

Creating A New User For Sp Execution Say Sa (to Whom I Am In Need Of Creating Under My User Defined Db )

Jul 11, 2007

I am in need of creating a new user for stored procedures execution say sa (to whom i am in need of creating under my user defined db)

View 1 Replies View Related

Query Runs Fine In Query Analyser But Not The Query Debugger

Dec 19, 2003

I'm running a query, actually its an insert that works when using the TSQL below.

However when I try to use the debugger to step through and using the exact same values as those below I get the following error:

[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

Its Killing me because everything else works, but this. Can somebody help.


DECLARE @NoteID INT,-- NULL OUTPUT,
@Note_Description NVARCHAR(3000),-- = NULL,
@Date DateTime,-- = NULL OUTPUT,
@ByWho NVARCHAR(30),-- = NULL,
@FK_Action_Performed NVARCHAR(40),-- = NULL,
@FK_UserID INT,-- = NULL,
@FK_JobID INT,-- = NULL,
@Job_Date DateTime,-- = NULL,
@Start DateTime,-- = NULL,
@Finish DateTime,-- = NULL,

@BeenRead NVARCHAR(10),-- = NULL

@FK_UserIDList NVARCHAR(4000)-- = NULL


--SET @NoteID = 409 --NULL OUTPUT,
SET @Note_Description = 'Tetsing'
--SET @Date DateTime = NULL OUTPUT,
SET @ByWho = 'GeorgeAgaian'
SET @FK_Action_Performed = 'Worked hard'
SET @FK_UserID = 5
SET @FK_JobID = 29
SET @Job_Date = 28/01/03
SET @Start = '1:00:20 PM'
SET @Finish = '1:00:20 PM'
SET @BeenRead = 'UnRead'

SET @FK_UserIDList = '1,2,3'


--AS

--SET NOCOUNT ON


SET NOCOUNT ON

SET XACT_ABORT ON

BEGIN TRANSACTION

SET @Date = GETDATE()

-- Insert Values into the customer table
INSERT Note (Note_Description,
Date,
ByWho,
FK_Action_Performed,
FK_UserID,
FK_JobID,
Job_Date,
Start,
Finish)

SELECT --@NoteID,
@Note_Description,
@Date,
@ByWho,
@FK_Action_Performed,
@FK_UserID,
@FK_JobID,

@Job_Date,
@Start,
@Finish

-- Get the new Customer Identifier, return as OUTPUT param
SELECT @NoteID = @@IDENTITY


-- Insert new notes for all the users that the note pertains to, in this case this will be by the assigned
-- users.
IF @FK_UserIDList IS NOT NULL
EXECUTE spInsertNotesByAssignedUsers @NoteID, @FK_UserIDList

-- Insert New Address record
-- Retrieve Address reference into @AddressId
-- EXEC spInsertForUserNote
-- @FK_UserID,
--@NoteID,
-- @BeenRead
-- @Fax,
-- @PKId,
-- @AddressId OUTPUT

COMMIT TRANSACTION

--------------------------------------------------
GO

View 1 Replies View Related

Query Diff Results From Ent Manager Query And Query Analizer

May 28, 2008

ok can someone tell me why i get two different answers for the same query. (looking for last day of month for a given date)

SELECT DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(m, 0, CAST('12/20/2006' AS datetime)) + 1, 0)) AS Expr1
FROM testsupplierSCNCR
I am getting the result of 01/01/2007

but in query analizer I get the result of

12/31/2006

Why the different dates

View 4 Replies View Related

Creating UDT From Another UDT

Jul 20, 2005

Hi,I have a User Defined Datatype, which I want to use to define anotherdata-type. I tried the obvious:EXEC sp_addtype@typename = UDT_OBJECT_ID,@phystype = 'NUMERIC (5)',@nulltype = 'NULL'GOEXEC sp_addtype@typename = UDT_TRACKING_NUM,@phystype = UDT_OBJECT_ID,@nulltype = 'NOT NULL'GObut that didn't work :Msg 15036, Level 16, State 1, Server SKINNER, Procedure sp_addtype, Line 186The data type UDT_OBJECT_ID does not exist.Has anyone done this before,Thanks,Rowland.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved