Viewing 15 posts - 2,311 through 2,325 (of 2,458 total)
Add USE statement to a proc (using DSQL):
CREATE PROC xxx AS
BEGIN
DECLARE @sql varchar(100)='USE tempdb; SELECT * FROM sys.database_files;'
EXEC(@sql);
SET @sql='USE master; SELECT * FROM sys.database_files;'
EXEC(@sql);
END
You can also accomplish this using the...
January 8, 2013 at 3:51 pm
I can't speak to TVPs but I use this technique to create a default value in stored procedures and functions have seen it used quite often.
I have always been...
January 8, 2013 at 3:44 pm
Great article Dwain! It also inspired me to read the N-Tuple article which I liked.
Itβs almost a shame (not really! J) that I no longer support Accounting applications because...
January 8, 2013 at 1:30 pm
Edit: misread ddl. Said something stupid.
I tried to solve this and failed. Well done Dwain C.
January 3, 2013 at 12:48 pm
There are some nuances I wont cover here but should work or at least get you started.
To export a query from SQL Server to comma delimited CSV file
1) Right-click...
January 3, 2013 at 11:38 am
On the other side... I have never run REPAIR_ALLOW_DATA_LOSS.
January 2, 2013 at 7:46 pm
This is not the most elegant or optimized approach but this will get you the result set that you are looking for...
--Parameter
DECLARE @topMonth int=3;
--if a valid month is not...
January 2, 2013 at 7:11 pm
dwain.c (12/17/2012)
If you think those "typos" that pass SQL Server's parser seem weird, try this one:
SELECT 7+$
Thanks for the post dwain. That's really odd too; I would never think to...
December 18, 2012 at 8:57 am
Another way:
DECLARE @spitme TABLE (Item varchar(40));
INSERT @spitme VALUES ('HEYE-B Euro-IPA 69793'), ('HEYE-B RFE-IPA 70940');
SELECT SUBSTRING(Item, CHARINDEX(' ',Item)+1, LEN(Item)-(CHARINDEX(' ',Item)+CHARINDEX(' ',REVERSE(Item))))
FROM @spitme
Fun.
December 18, 2012 at 1:12 am
Using Jeff Moden's splitter[/url] you can do this...
DECLARE @spitme TABLE (Item varchar(40));
INSERT @spitme VALUES ('HEYE-B Euro-IPA 69793'), ('HEYE-B RFE-IPA 70940');
SELECT s.Item
FROM @spitme val
CROSS APPLY test.[dbo].[DelimitedSplit8K](val.Item,' ') s
WHERE ItemNumber = 2
December 17, 2012 at 5:49 pm
Your typo messed me up too...
You can also try:
;WITH x AS
(SELECT ID, Stat, StatDate
FROM #Apps
WHERE Stat='AppRec' AND StatDate >= '2012-12-01' )
SELECT ID, Stat, StatDate
FROM #Apps
WHERE ID...
December 17, 2012 at 5:03 pm
zilla (12/17/2012)
December 17, 2012 at 3:45 pm
In case anyone was curious - the line in the Ben Gan book I was referring to is:
The SQL Server documentation indicates that not terminating T-SQL statements with a semicolon...
December 17, 2012 at 11:58 am
Viewing 15 posts - 2,311 through 2,325 (of 2,458 total)