It certainly was, thanks very much riverguy!
I renamed the parameter, declared a variable with the old name of the parameter, set the variable to = the parameter, and hey presto!
Could someone please explain to me the difference in how a stored proc runs compared to just raw sql outside of a stored proc?
I created a query which creates 2 temp tables and loads them with data, then creates a 3rd temp table, inserts some rows with titles in the first column, and populates...
Got it !
I just had to create a temp table and fill it with data, then drop it, SSRS looks at this temp table and takes the columns from it:
CREATE TABLE #Temp1
(
CreateDate VARCHAR(8)
)
SET @MonthsCounter = 1
DECLARE @ColumnCreator NVARCHAR(MAX)
WHILE @MonthsCounter <=...
Hi Markros,
Thanks for the tip, you're right, I hadn't used dynamic pivots before, and had only really brushed on basic pivots, so I have it functional now, producing the correct results. I had to recode the column headers string a couple of times to get it how it has been requested, but it...
Hi Guys,
I'm hoping someone can help here because this has caused a lot of head scratching over the past few weeks.
I know of the PIVOT function to switch rows into columns, but this means the columns also become rows, therefore the row number is fixed, I would like to create a report that will...
just to clarify, I said i put + '' between each CHAR(9) but on this forum it looks like a plus sign then a double quote mark, its actually 2 singles like ' ' with no space between them :]
Hi Crowley, I ran the full thing from start to finish and found some strange things, but it worked in the end for what I wanted, with some minor tweaking.
-SSMS 'Results to Text' worked
-SSMS 'Results to Grid' replaced tabs with spaces
-SSRS outputted a single space instead of the correct number...
You're right I can now see the tabs correctly when viewing "Results to text", but I need the final output in SSRS, so the results need to be in grid format, SSRS doesn't seem to pick it up in text mode.
Thanks for the input though, I never realised it was doing it properly in text mode.
Hi there,
I'm trying to insert a TAB into my output in SQL Server 2005 but it just represents it as a SPACE.
First I tried the following syntax with the TAB manually put in the string:
SELECT 'test1 test2'
And also using CHAR(9) like:
SELECT 'test1' + CHAR(9) + CHAR(9) + CHAR(9) + CHAR(9) +...
When and why would you ever use 'cast' over 'convert'?
I presume there is a slight difference in speed as cast doesn't do quite as much as convert, but surely the difference would be so small that it is insignificant.
Would you only use cast to make scripts more portable for other SQL...
You're right i didnt want the time, i never realised this :] Thanks for the followup I get it better now, will look into ammending things as soon as I have time.
Cheers :]
Thanks to everyone who replied, really appreciate it. I tried and tested each method to the best of my understanding, but in the end, went with PHVs way of doing it with input from remou. tbh i didnt really understand dhookom's way, and golum, your way is a really clean cut way of doing it, i...
Im trying to get the date of the previous day as specified at code level (i have a form for each day of the week so it will change from form to form).
Basically I want a variable containing the date of the previous monday for example (but could be any day), including today, so if this is monday...
Why are GOTO statements bad?
I've been writing SQL without any GOTO statements but recently became aware that they can be used in SQL Server 2005, but when I try to research it, people just flame the use of it.
Everyone says it's bad practice, and there are almost always more elegant...
I tried the example i gave in the first post with and without the N and i get the same results for both. So why do we need the N?
EXAMPLES:
SELECT * FROM sys.objects WHERE type IN (N'P', N'PC')
SELECT * FROM sys.objects WHERE type IN ('P', 'PC')
ok thanks, i would have thought that a string would automatically be converted to the correct string type though. Does any hardcoded nvarchar need to have an N before the actual string then?
You need to do a subquery in the WHERE clause to select the record with the maximum date. Something like the following (change it around as needed but you should be able to see where im going with it):
SELECT *
FROM Treatment
RIGHT JOIN Episode
ON
episode.system_code = treatment.system_code...
What does N do? I'm looking at some code which I understand for the most part, but if I were writing it I wouldnt use N in it, I don't know what N does so was just wondering if someone could explain it to me please.
EXAMPLE:
SELECT * FROM sys.objects WHERE type IN (N'P', N'PC')
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.