I am getting an issue when I am using a stored proc from a view.
I am to returning values, one being a varchar(50).
When I run the view, the values for this column and all others are returned fine.
When I run the stored procedure, the following error is shown:
Conversion failed when converting the varchar value 'ejoy' to data type int.
All other values return fine bar this one column and as I said its already a varchar in the table so I don't know why sql server (2005) thinks I want to convert it, I don't and at no point have tried to.
Below is my query statement
quote:SELECT u.User_fname, pv.PV_address, p.Start_monitoring, p.Last_monitoring, p.Period_of_monitoring, m.Ongoing_maintenance,
m.Savings_for_inverter_replacement, m.Monitoring, m.Total_anual_maint_and_monitor
FROM PerformanceData p, MonitoringCost m, Photovoltaic pv, Users u
WHERE p.Performance_id=m.MonitoringCost_id and
pv.PV_id=p.Performance_id and
pv.PV_id=m.MonitoringCost_id and
u.User_id =p.Performance_id and
u.User_id =pv.PV_id and
u.User_id = m.MonitoringCost_id
This error has been displayed
quote:Conversion failed when converting the varchar value 'ejoy' to data type int.
I am trying to write a query that give me how many items were filed per year.
This is the error:
Conversion failed when converting the varchar value 'YEAR(1999)' to data type int.
Here is the query I am using:
SELECT COUNT (*), CASE WHEN ChargesFiledDate > 20141231 THEN 'YEAR (2015)' WHEN ChargesFiledDate > 20131231 THEN 'YEAR (2014)' WHEN ChargesFiledDate > 20121231 THEN 'YEAR (2013)' ELSE YEAR (0000)
[Code] ...
And got the same error. I know there is probably a better way to get this data (being that I need it from 2007 to present), but don't know how to write it.
Hi: here i am giving one example with Emp table and fields ssn,empjoindate
I have a table with field empjoindate as varchar(10).I need number of employees joined between 12/23/01 and 01/04/02.I ran this query using select ssn from EMP where convert(varchar(10),empjoindate,101) between '12/23/01' and '01/04/02'.it is not fetching any data.
Can someone please explain to me how the datapages in Microsoft SQL Server 2000 works. The pages are supposed to be 8K, that is 8192 bytes of which only 8060 are accessible for data storage (due to overhead). Now, I currently have a table containing 8 fields. Two of these fields are varchar and should be converted to nvarchar. One of the varchar fields is limited to 255 characters and the other to 4000 characters. When I convert the 255 characters field to nvarchar it works just fine, but when I want to convert the 4000 characters field I get an error from MS SQL saying that it gets to big. Is the error only for the 4000 characters field (which growths to 8000 bytes when using nvarchar instead of varchar) or must the whole table fit into one datapage? Could a blob maybe solve my problem, or will I face new problems when storing unicode characters in a blob?
Is it possible to convert a nText column in the source to varchar in the destination. I tried using a DataConversion block but there is no option for Ntext, I think am misising somehting here. Can someone guide me here?
Hello All, I am querying from a table which has all varchar values. I want to display the result in graph and hence would need the varchar to be converted to Decimal. But I am getting the error : Error converting data type varchar to Numeric. Here is the SELECT code: Can you please help me do this? I'll post the script in the next post in 10 minutes....
why do i have this error? not converting a varchar into int 1 ALTER PROCEDURE dbo.RevertDB 2 ( 3 @Log varchar(MAX) = NULL OUTPUT 4 ) 5 6 /* Reverts Database to original "Clean" State */ 7 AS 8 SET NOCOUNT OFF 9 DECLARE @RowsInDB AS int 10 SET @Log = 'RevertDB Started at ' + CAST(GETDATE() AS varchar(50)) + '<br />' 11 12 /* *** Disable Constraints *** 13 ALTER TABLE Booking NOCHECK CONSTRAINT ALL 14 ALTER TABLE InventoryPC NOCHECK CONSTRAINT ALL 15 ALTER TABLE PC NOCHECK CONSTRAINT ALL 16 ALTER TABLE Platform NOCHECK CONSTRAINT ALL*/ 17 18 /* *** Start Deletes *** */ 19 DELETE FROM Booking 20 SET @Log = @Log + 'Clear Table Booking - Done' + '<br />' 21 SET @RowsInDB = (SELECT COUNT(BookingID) FROM Booking) 22 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + '<br />' 23 24 DELETE FROM InventoryPC 25 SET @Log = @Log + 'Clear Table InventoryPC - Done' + '' 26 SET @RowsInDB = (SELECT COUNT(InventoryID) FROM InventoryPC) 27 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + '<br />' 28 29 DELETE FROM PC 30 SET @Log = @Log + 'Clear Table PC - Done' + '<br />' 31 SET @RowsInDB = (SELECT COUNT(PCID) FROM PC) 32 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + '<br />' 33 34 DELETE FROM Platform 35 SET @Log = @Log + 'CLear Table Platform - Done' + '' 36 SET @RowsInDB = (SELECT COUNT(PlatformID) FROM Platform) 37 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + '<br />' 38 39 /* *** Enable Constraints *** 40 ALTER TABLE Booking WITH CHECK CHECK CONSTRAINT ALL 41 ALTER TABLE InventoryPC WITH CHECK CHECK CONSTRAINT ALL 42 ALTER TABLE PC WITH CHECK CHECK CONSTRAINT ALL 43 ALTER TABLE Platform WITH CHECK CHECK CONSTRAINT ALL*/ 44 45 SET @Log = @Log + '*** End Truncates ***' + '<br />' 46 /* *** End Truncates *** */ 47 48 /* *** Start Insert Platform *** */ 49 SET @Log = @Log + 'Start Insert Platform' + '<br />' 50 51 EXEC dbo.InsertPlatfrom 'Windows XP SP2 Professional Edition', 'Some description for Windows XP SP2 Professional Edition over here …' 52 EXEC dbo.InsertPlatfrom 'Windows Vista Ultimate', 'See everything you''re working on more clearly with Windows Aero, and quickly switch between windows or tasks using Windows Flip 3D and Live Thumbnails. You can easily find what you need—when you need it―with Instant Search and live icon previews that display the actual contents of your files. And while you''re at it, give your personal productivity a boost with instant access to the information you care about using Windows Sidebar and Gadgets. Put these easy-to-use and customizable mini-applications on your desktop and reveal the information you''re looking for at a glance. Website: http://www.microsoft.com/windows/products/windowsvista/seeit/default.mspx' 53 EXEC dbo.InsertPlatfrom 'Apple Mac OS X Tiger', 'Some description for Apple Mac OS X Tiger over here …' 54 EXEC dbo.InsertPlatfrom 'Apple Mac OS X Leopard', 'Desktop: The new look of Leopard showcases your favorite desktop image and puts new file Stacks at your fingertips for a stunning, clutter-free workspace. Finder: Browse your files like you browse your music with Cover Flow. Time Machine: See how your system looked on any given day and restore files with a click. Website: http://www.apple.com/macosx/leopard/features/' 55 EXEC dbo.InsertPlatfrom 'Red Hat Linux', 'Some description for Red Hat Linux over here …' 56 57 SET @Log = @Log + 'Rows In Platform: ' + CAST((SELECT COUNT(PlatformID) FROM Platform) AS varchar(10)) + '<br />' 58 /* *** Start Insert PC *** */ 59 SET @Log = @Log + 'Start Insert PC' + '<br />' 60 61 DECLARE @WinXP int, @WinVista int, @OSXTiger int, @OSXLeopard int, @RedHat int 62 SET @WinXP = (SELECT PlatformID FROM Platform WHERE Title = 'Windows XP SP2 Professional Edition') 63 SET @WinVista = (SELECT PlatformID FROM Platform WHERE Title = 'Windows Vista Ultimate') 64 SET @OSXTiger = (SELECT PlatformID FROM Platform WHERE Title = 'Apple Mac OS X Tiger') 65 SET @OSXLeopard = (SELECT PlatformID FROM Platform WHERE Title = 'Apple Mac OS X Leopard') 66 SET @RedHat = (SELECT PlatformID FROM Platform WHERE Title = 'Red Hat Linux') 67 68 EXEC dbo.InsertPC 'Fusion PC One', 'Description here ...', 'Intel Core2 Duo E6600 2.4 GHz 1066MHz', '1GB Dual Channel DDR2 667 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3', '22" 3000:1 Wide Screen LCD', @WinXP 69 EXEC dbo.InsertPC 'Fusion PC Two', 'Description here ...', 'Intel Core2 Duo E6850 3 GHz 1333MHz', '2GB Dual Channel DDR2 800 SDRAM', '240GB SATA2 NCQ HDD', 'NVIDIA GeForce 8800 Ultra 256MB GDDR3 SLI', '24" 3000:1 Wide Screen LCD', @WinVista 70 EXEC dbo.InsertPC 'Fusion PC Three', 'Description here ...', 'AMD Athlon 64 X2 Dual Core 6000+ 3 GHz', '2GB Dual Channel DDR2 667 SDRAM', '240GB SATA2 NCQ HDD', 'ATI Radeon Cross Fire 2900 256MB GDDR3', '24" 3000:1 Wide Screen LCD', @WinVista 71 EXEC dbo.InsertPC 'Fusion X1', 'Description here ...', 'Intel Core2 Extreme Q6850 3 GHz 1333MHz', '6GB Dual Channel DDR2 800 SDRAM', '500GB SATA2 NCQ HDD', 'NVIDIA GeForce 8800 Ultra 256MB GDDR3 SLI', '30" 3000:1 Wide Screen LCD', @OSXLeopard 72 EXEC dbo.InsertPC 'Fusion X2', 'Description here ...', 'AMD Athlon 64 FX 74 3 GHz', '6GB Dual Channel DDR2 800 SDRAM', '500GB SATA2 NCQ HDD', 'NVIDIA GeForce 8900 Ultra SLI 256MB GDDR3', '30" 3000:1 Wide Screen LCD', @WinVista 73 EXEC dbo.InsertPC 'Fusion Tiger 1', 'Description here ...', 'Intel Core2 Duo E6600 2.4 GHz 1066MHz', '2GB Dual Channel DDR2 800 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3 SLI', '22" 3000:1 Wide Screen LCD', @OSXTiger 74 EXEC dbo.InsertPC 'Fusion Linux 1', 'Description here ...', 'AMD Athlon 64 X2 6000+ 3 GHz', '1GB Dual Channel DDR2 800 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3', '22" 3000:1 Wide Screen LCD', @RedHat 75 76 SET @Log = @Log + 'Rows In PC: ' + CAST((SELECT COUNT(PCID) FROM PC) AS varchar(10)) + '<br />' 77 78 /* *** Start Insert Inventory *** */ 79 SET @Log = @Log + 'Start Insert Inventory' + '<br />' 80 81 DECLARE @F1 int, @F2 int, @F3 int, @FX1 int, @FX2 int, @FT1 int, @FR1 int 82 SET @F1 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC One') 83 SET @F2 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC Two') 84 SET @F3 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC Three') 85 SET @FX1 = (SELECT PCID FROM PC WHERE Title = 'Fusion X1') 86 SET @FX2 = (SELECT PCID FROM PC WHERE Title = 'Fusion X2') 87 SET @FT1 = (SELECT PCID FROM PC WHERE Title = 'Fusion Tiger 1') 88 SET @FR1 = (SELECT PCID FROM PC WHERE Title = 'Fusion Linux 1') 89 90 EXEC dbo.InsertInventory 10, @F1, 2.5, 'iCluster Fusion One' 91 EXEC dbo.InsertInventory 10, @F2, 2.5, 'iCluster Fusion Two' 92 EXEC dbo.InsertInventory 10, @F3, 2.5, 'iCluster Fusion Three' 93 EXEC dbo.InsertInventory 6, @FX1, 6, 'iCluster Fusion X1' 94 EXEC dbo.InsertInventory 6, @FX2, 6, 'iCluster Fusion X2' 95 EXEC dbo.InsertInventory 10, @FT1, 3, 'iCluster Fusion Tiger One' 96 EXEC dbo.InsertInventory 30, @FR1, 2, 'iCluster Fusion Linux One' 97 98 SET @Log = @Log + 'Rows In Inventory: ' + CAST((SELECT COUNT(InventoryID) FROM InventoryPC) AS varchar(10)) 99 100 RETURN @Log if i remove the last line then all is well. but i get "An SqlParameter with ParameterName '@Log' is not contained by this SqlParameterCollection."
select case when count(convert(varchar(15), customer_id)) = 1 Then 'only one customer' else count(convert(varchar(15), kund_id)) end as no_of_customers, salesperson_id from customerdb group by salesperson_id
...and this is the result I was hoping for
no_of_customers ; salesperson_id 3 ; 1 2; 2 only one customer;3
...but SQL server only returns: Conversion failed when converting the varchar value ...
Basically, I'm trying to take two dates and find the difference in hours b/t the two, sql server 2000. I've tried change the variables out from datetime to varchars even though it shouldn't matter. When I put the block of code out of the stored procedure and run it in line it works fine, I'M LOST.........
I get the errors everytime it runs into the first block, I get the error again when the block is hit again farther down in the procedure. I get:
Server: Msg 242, Level 16, State 3, Procedure tmpRyan_spRail_Job_NoMovement, Line 211 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. Server: Msg 242, Level 16, State 1, Procedure tmpRyan_spRail_Job_NoMovement, Line 360 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. ERR dates Aug 4 2005 11:16PM. Server: Msg 242, Level 16, State 3, Procedure tmpRyan_spRail_Job_NoMovement, Line 211 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. Server: Msg 242, Level 16, State 1, Procedure tmpRyan_spRail_Job_NoMovement, Line 360 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. ERR dates Aug 3 2005 12:35PM. Server: Msg 241, Level 16, State 1, Procedure tmpRyan_spRail_Job_NoMovement, Line 211 Syntax error converting datetime from character string.
IF @NextStatusDate IS NOT NULL AND @StatusDate IS NOT NULL BEGIN set @tmpTimeCharVar = DATEDIFF(SECOND, @NextSTatusDate, @StatusDate) set @tmpTimeVar = ( CASE WHEN @tmpTimeCharVar/3600<10 THEN '0' ELSE '' END + RTRIM(DATEDIFF(SECOND,@NextSTatusDate, @StatusDate)/3600) + ':' + RIGHT('0'+RTRIM((@tmpTimeCharVar % 3600) / 60),2) + ':' + RIGHT('0'+RTRIM((@tmpTimeCharVar % 3600) % 60),2) ) END IF @@ERROR <>0 PRINT 'ERR dates' + Convert(varchar(20), @NextStatusDate) + '.'
I am having an issue with a Report in SSRS against a Sybase db.
The dataset for the report is a Sybase stored proc which is passed a parameter (varchar). When I run the proc in Sybase it runs fine, when I run it in SSRS in the data tab it runs fine, but when I try to preview the report, or run from IE after deploying it I get the following error:
An error has occurred during report processing. (rsProcessingAborted) Get Online Help Query execution failed for data set 'Table_1'. (rsErrorExecutingCommand) Get Online Help The given type name was unrecognized
Looks like it is an error converting the string in SSRS to a varchar in Sybase, but I don't know how to fix it.
If I create a table with an identity (int) column and the varchar column, join this to the proc and pass the int as the parameter the report works fine!! (This is not an option in production though.)
I am using SybaseASE OLE DB Provider Version 02.70.0032
CREATE PROC CLEAR_MY_TABLE @TableStat varchar(30) AS If OBJECT_ID('MyDB.dbo.' + @TableStat + '') is not null BEGIN ---PRINT 'I FOUND THE TABLE' DECLARE @count INT = -1; SELECT @count = (Select COUNT(*) FROM [dbo]. + @TableStat); IF (@count > 0) BEGIN TRUNCATE TABLE @TABLESTAT END
I am recieving the following error when executing the following code. Field MonData is nvarchar (80), the only integer feild in the concatination is @Cnt all other fields are varchar or nvarchar. If I remove the everything past space(22) it works fine. I double checked the length and it does not exceed 80 bytes. Can anyone see what I am doing wrong?
INSERT INTO tbl_Export Select DISTINCT TOP(1) space(32) + '9' + space(2) + @Cnt + space(2) + Sys + space(2) + Prin + space(22) + 'TEN' + space(1) + 'ZZ' As MonData FROM dbo.Trans WHERE Sys = @vwSys AND Prin = @vwPrin
ERROR: Conversion failed when converting the varchar value 'TEN' to data type int.
-- AssignedToTasks 32,'from (Select Distinct wft.*',' OVER(Order by task.TaskId desc)','','where IsActive=1 AND RecurrenceRule is null',0,5 Alter PROCEDURE [dbo].[AssignedToTasks]
There are a few databases I work with that have been designed where varchar columns are used to store what actually displays on the front end as Ints, Decimals, Varchars, Datetimes, checkboxes.
I often have to write integrations with these databases bringing data in and prefer to validate the data whilst loading from the staging tables.
I have seen allsorts of values being passed into the staging tables that will load into the target database because the columns are all varchars but the values don't display on the front end because the app actively filters bad values out.
What I would like to do is for my validation scripts to warn up front of potentially invalid datatypes. My problem is that forexample the ISNUMERIC() function return 1 for the value ',1234' but a CONVERT(NUMERIC, ',1234') or CAST(',1234' AS NUMERIC) will fail with a "Error converting data type varchar to numeric).
I've been trying to locate a set of reliable datatype testing functions that will reliably determine if a varchar can be converted to a given data type or not.
Within in Visual Studio 2012 solution, I have several projects, one of which is a Database project. I am defining several tables. The one in question is:
CREATE TABLE [dbo].[tblKppHierarchyPcl] ( [ID] NUMERIC(18,0) NOT NULL, [Name] VARCHAR(500), [PartStructureKey] NUMERIC(18,0) NOT NULL, [PartNumber] VARCHAR(500) NOT NULL, [ParentPartNumber] VARCHAR(500) NULL,
[code]...
Error SQL72014: .Net SqlClient Data Provider: Msg 245, Level 16, State 1, Line 76 Conversion.failed when converting the varchar value 'Coolant Quick Disconnect' to data type int.So it has a problem with inserting 'Coolant Quick Disconnect' into the Name column. The Name column is CLEARLY a varchar column but somehow it thinks it's an int column.
My query was working fine until I added the yellow highlighted areas below. Basically what I'm doing with this is getting the lowest open purchase order number (docnum) and its matching docduedate. Now when I run it I get
Conversion failed when converting the varchar value 'po_num' to data type int.
Any ideas? Thanks!
SELECT t3.product ,
t7.itemname ,
t2.u_vlgx_plc,
t3.shorted ,
t4.onhand ,
MIN(
CASE
WHEN t8.linestatus = 'O'
THEN t9.docnum
ELSE NULL
END) po_num,
t10.docduedate
FROM
(SELECT t0.product product ,
SUM(
CASE
WHEN t0.qty_topick <> t0.qty_picked
THEN t0.qty_topick - t0.qty_picked
ELSE 0
END) shorted
FROM rbeacon.dbo.shipline2 t0
INNER JOIN rbeacon.dbo.shiphist t1
ON t0.packslip = t1.packslip
WHERE t1.date_upld = CONVERT(VARCHAR(10), GETDATE()-1, 101)
GROUP BY t0.product
) t3
INNER JOIN comparison.dbo.vlgxplc t2
ON t2.itemcode = t3.product COLLATE Latin1_General_CI_AS
LEFT JOIN
(SELECT t0.product AS product,
SUM(t0.quantity) AS onhand
FROM rbeacon.dbo.binlocat t0
GROUP BY t0.product
) t4
ON t3.product = t4.product
INNER JOIN wbau.dbo.oitm t5
ON t3.product = t5.itemcode COLLATE SQL_Latin1_General_CP850_CI_AS
LEFT JOIN wbau.dbo.ocrd t6
ON t5.cardcode = t6.cardcode
INNER JOIN wbau.dbo.oitm t7
ON t3.product = t7.itemcode COLLATE SQL_Latin1_General_CP850_CI_AS
LEFT JOIN wbau.dbo.por1 t8
ON t3.product = t8.itemcode COLLATE SQL_Latin1_General_CP850_CI_AS
I'm trying to pass a character (D) to an integer data type!i'm getting this error:Conversion failed when converting the varchar value '17D' to data type int.
Hi, I need help. Understatement of the year right now, too = So... I've created a stored procedure that partially pulls a SQL union query to give me a complete one-line result set of a bunch of data... four separate selects comprise the query. The tables are structured identically to each other, but the values being pulled are specific and distinct. All of the non-date values stored are varchar values in the tables, and yet when I execute the SQL union query, I get the error message: Syntax error converting the varchar value to a column of data type int. I know SQL does implicit conversions, however Im not sure why it's trying to do that with this query, I suppose. it should have been straightforward. Any suggestions? Here is the query logic to look at, in case I'm missing the obvious
exec(' SELECT ACCOUNT, LNAME, FNAME, SEX, DOB, cast(MA_ContentValue as decimal) as MA_ContentValue, cast(MA_DOS as smalldatetime) as MA_DOS,cast(LDL_ContentValue as decimal) as LDL_ContentValue, cast(LDL_DOS as smalldatetime) as LDL_DOS, cast(HgbA1C_ContentValue as decimal)as HgbA1C_ContentValue, HgbA1C_DOS, cast(Creatinine_ContentValue as decimal) as Creatinine_ContentValue, Creatinine_DOS FROM ( SELECT Account, Lname, FName, Sex, DOB,MA_ContentValue, MA_DOS, 0 as LDL_ContentValue, 0 as LDL_DOS, 0 as HgbA1C_ContentValue, 0 as HgbA1C_DOS, 0 as Creatinine_ContentValue, 0 as Creatinine_DOS FROM dbo.vwDiabetic_MicroalbuminTop3 UNION SELECT Account, Lname, FName, Sex, DOB, 0 as MA_ContentValue, 0 as MA_DOS, LDL_ContentValue, LDL_DOS, 0 as HgbA1C_ContentValue, 0 as HgbA1C_DOS, 0 as Creatinine_ContentValue, 0 as Creatinine_DOS FROM dbo.vwDiabetic_LDLTop3 UNION SELECT Account, Lname, FName, Sex, DOB, 0 as MA_ContentValue, 0 as MA_DOS, 0 as LDL_ContentValue, 0 as LDL_DOS, HgbA1C_ContentValue, HgbA1C_DOS, 0 as Creatinine_ContentValue, 0 as Creatinine_DOS FROM dbo.vwDiabetic_HgbA1CTop3 UNION SELECT Account, Lname, FName, Sex, DOB, 0 as MA_ContentValue, 0 as MA_DOS, 0 as LDL_ContentValue, 0 as LDL_DOS, 0 as HgbA1C_ContentValue, 0 as HgbA1C_DOS, Creatinine_ContentValue, Creatinine_DOS FROM dbo.vwDiabetic_CreatinineTop3) tbl1
') Anything else that I can provide for someone to help me? I appreciate any/all feedback!
I try to compile your query, and prompt error message in below 'conversion failed when converting the varchar value 'times' to data type int .Error code 245.
select user_member , sum(case when trx_date > dateadd(month, -3, getdate()) then 1 else 0 end) + ' times' , max(case when trx_date < dateadd(month, -3, getdate()) then trx_date else NULL end) from trx_hdr group by user_member
CASE WHEN NULLIF(NHSNo2, '') IS NULL THEN 1 WHEN NULLIF(Surname, '') IS NULL THEN 2 WHEN NULLIF(Forename, '') IS NULL THEN 3 WHEN NULLIF(DOB, '') IS NULL OR DOB < '01/01/1900' THEN 4 WHEN NULLIF(AddressLine1, '') IS NULL THEN 5
[code]...
The above code worth great but ideally instead of returning a number Id like to return text for example
I got this erorr when trying to create my stored proc,
What do i need to fix, and how do i fix it?!!
Msg 457, Level 16, State 1, Procedure PROC_DAILY_ACTIVITY, Line 13
Implicit conversion of char value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.
Code Block set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go
-- ============================================= -- Author: <Zaccheus,Tenchy> -- Create date: <NOVEMEBER,12,2007> -- Description: <Reporting stored procedure,DAILY ACTIVITY,> -- ============================================= CREATE PROCEDURE [dbo].[PROC_DAILY_ACTIVITY] (@Region_Key int=null) AS BEGIN SELECT Region_Key, Null as Customer_Code, Non_Customer_Activities.Question_code, Non_Customer_Activities.Description, Region AS Region, Name AS Territory_Name, Non_Customer_Activities.Que_Desc AS Store_Name, Non_Customer_Activities.Logged_Time AS TheDate, Non_Customer_Activities.response AS Response, Null as is_Visit_Fg FROM [FSSRC].[dbo].Qry_Sales_Group Sales_Group INNER JOIN (Select QH.[question_code] ,Question_Header.Description ,CONVERT(datetime,DATEADD(day, (qh.cycle_day-1), p.start_date),6) Logged_Time ,SUBSTRING([entity_code],1,5) SR_Code ,[response] ,Territory_Code SR_Territory_Code ,'Not Customer Related' Que_Desc From question_history QH INNER JOIN Period P ON p.period_code = qh.period_code INNER JOIN [RC_DWDB_INSTANCE_1].[dbo].[Tbl_Territory_In_Sales_Responsible] as Territory_In_Sales_Responsible ON Territory_In_Sales_Responsible.SalesPerson_Purchaser_Code=SUBSTRING([entity_code],1,5) COLLATE Latin1_General_CI_AS INNER JOIN dbo.questions Question_Header ON Question_Header.question_code = QH.question_code WHERE [entity_code] like '%.USER%' AND Question_Header.Question_Code IN('AME01','ASE01','ACO01','ALU01','AOS01','APH01','ATR01','ATE01','ACR06','ACR05','ACR02','ACR03','ACR08','ACR07') AND CONVERT(datetime,DATEADD(day, (qh.cycle_day-1), p.start_date),6) = '11/9/2007' ) Non_Customer_Activities ON Sales_Group.Code = Non_Customer_Activities.SR_Territory_Code UNION ALL SELECT Customer_Activities.Customer_Code, NULL, NULL, Region AS Region, Name AS Territory_Name, Customer_Activities.Customer_Name AS Store_Name, Customer_Activities.Logged_Time AS TheDate, NULL AS Response, is_Visit_Fg FROM [FSSRC].[dbo].Qry_Sales_Group Sales_Group INNER JOIN (Select distinct time_log Logged_Time ,[entity_code] Customer_Code ,[name] Customer_Name ,Territory_Code Cust_Territory_Code ,MAX(is_Visit_Fg) Is_Visit_Fg From question_history QH INNER JOIN Period P ON p.period_code = qh.period_code INNER JOIN dbo.questions Question_Header ON Question_Header.question_code = QH.question_code INNER JOIN [FSSRC].[dbo].[customer] ON Entity_Code = [customer_code] INNER JOIN [FSSRC].[dbo].[visit] V ON V.[customer_code] = QH.[entity_code] AND V.[period_code] = QH.[period_code] AND V.[cycle_day] = QH.[cycle_day] INNER JOIN [RC_DWDB_INSTANCE_1].[dbo].[Tbl_Territory_In_Sales_Responsible] as Territory_In_Sales_Responsible ON Territory_In_Sales_Responsible.SalesPerson_Purchaser_Code=[sales_person_code] COLLATE Latin1_General_CI_AS WHERE [entity_code] NOT like '%.USER%' AND Convert(datetime,convert(Varchar,time_log,110)) = '11/9/2007'
GROUP BY time_log ,[entity_code] ,[name] ,Territory_Code ) Customer_Activities ON Sales_Group.Code = Customer_Activities.Cust_Territory_Code WHERE @Region_Key=Region_Key order by 4 END