Viewing 15 posts - 3,646 through 3,660 (of 5,111 total)
If you want to set the values of multiple variables in a single statement, you can use the SELECT statement:SELECT @ItemName = item_name,
@Category = category
June 22, 2017 at 8:46 am
Instead of an IF statement, why not a CASE expression?
SELECT oi.item_name
CASE oi.item_name WHEN 'Pen' THEN 'Accessories'
WHEN 'Pencil' THEN 'Accessories'
WHEN 'Cable'...
June 22, 2017 at 8:28 am
June 22, 2017 at 7:46 am
Could you perhaps format your code so that it's readable please? Having a CASE expression with each part on a separate line with 3 blank lines inbetween makes in completely...
June 22, 2017 at 7:09 am
This isn't editing your code, but I've had a similar problem with an SSIS task that needs to be called from the our website. When the task is kicked off,...
June 22, 2017 at 6:23 am
SQL Server 2017 is in CTP at the moment, I'm not sure it was be advisable to upgrade your current version to a test product. You would be better setting...
June 21, 2017 at 7:14 am
WITH E1 AS (
SELECT 1 AS N UNION...
June 21, 2017 at 6:23 am
You say your have variables, but these are column names in your query. Variables start with an @ at the beginning.
You could use a CTE to do this...
June 21, 2017 at 2:14 am
As Jeff suggested, a TVF would be a much better option than a Scalar funciton for performance. So you could do something like this:CREATE FUNCTION dbo.LastBuyer_tvf (@SC1...
June 21, 2017 at 2:02 am
June 21, 2017 at 1:48 am
You're using your CASE expression incorrectly.
Try:ALTER FUNCTION [dbo].[LastBuyer]
(@SC1 varchar(30), @CIE varchar(1))
RETURNS VARCHAR(3)
AS
BEGIN
DECLARE @LB VARCHAR(3)
SELECT @LB = CASE...
June 20, 2017 at 10:06 am
June 20, 2017 at 2:12 am
Just to point to put, that isn't exactly what you asked. That query returns a list of logins that have their default Schema set to dbo on the current database.
June 19, 2017 at 10:36 am
Do you mean?SELECT SYSTEM_USER AS ServerLogin, CURRENT_USER AS DatabaseUser;
June 19, 2017 at 9:27 am
Perhaps something like:CREATE TABLE #Sample
(Org_ID varchar(20),
Amount decimal(12,2),
date date); --That is not confusing... </sarcasm> 😉
GO
INSERT INTO #Sample
June 19, 2017 at 8:15 am
Viewing 15 posts - 3,646 through 3,660 (of 5,111 total)