Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

T-SQL Expand / Collapse
Author
Message
Posted Saturday, January 1, 2011 3:43 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 1:27 AM
Points: 1,130, Visits: 1,390
Comments posted to this topic are about the item T-SQL

Thanks
Post #1041579
Posted Saturday, January 1, 2011 4:45 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:48 PM
Points: 5,332, Visits: 25,263
Nice question, got it right on a hunch .... but still learned something .. thanks

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #1041586
Posted Sunday, January 2, 2011 5:16 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 8:15 AM
Points: 13,017, Visits: 10,800
Thanks, great question.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1041618
Posted Sunday, January 2, 2011 8:44 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:11 PM
Points: 5,361, Visits: 8,924
Excellent question, thanks!

The only thing that is missing is how to solve this type of problem - you need to split the items in the variable into their separate items, and return them as a table that can be joined or cross-applied to. Jeff Moden wrote (and several people here have contributed to) a "DelimitedSplit8K" function; a quick google search shows many posts where it's been used/referenced.


Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
Post #1041690
Posted Monday, January 3, 2011 2:50 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Wednesday, September 21, 2011 4:03 AM
Points: 713, Visits: 100
Thanks Wayne :)

I was aware of this issue since long time, but didn't had any solution.

Thanks for sharing wonderful information with us.

Regards,


--------------------------------------------------------------------------------
Mayank Parmar
Software Engineer

Clarion Technologies
SEI CMMI Level 3 Company

8th Floor, 803, GNFC info Tower,
SG Highway, Ahmedabad - 380 054,
Gujarat, India.
www.clariontechnologies.co.in

Email: mayank.parmar@clariontechnologies.co.in
MSN : mayank.parmar@clariontechnologies.co.in
Mobile: +91 9727748789
--------------------------------------------------------------------------------
Post #1041746
Posted Monday, January 3, 2011 3:13 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 7:39 AM
Points: 1,426, Visits: 1,841
Very good, basic question, Hardik!

This QotD reminds us to be cautious when working with the IN keyword, especially in dynamic SQL.

Have a Happy New Year ahead!


Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Be courteous. Drive responsibly.

Follow me on
Twitter: @sqltwins
Google Plus: +Nakul
Post #1041751
Posted Monday, January 3, 2011 5:20 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:48 PM
Points: 6,021, Visits: 8,290
Great question!

I see so many people posting to forums or newsgroups, asking why they can't use IN (@variable) in this way with a comma-delimited list in the variable, that it's good to enforce this knowledge with a question.
And I'm glad to see that as of now, 80% of the people who answered have it right - I'm becoming a bit more optimistic about my fellow people now



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1041771
Posted Monday, January 3, 2011 7:06 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, February 26, 2011 11:22 PM
Points: 6, Visits: 11
it is avery helpful Question ..

regards all


Eng.Heba Mahmoud
Post #1041833
Posted Monday, January 3, 2011 8:55 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 5:55 PM
Points: 17,728, Visits: 15,593
Thanks for the question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1041884
Posted Monday, January 3, 2011 10:13 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, May 14, 2014 10:11 PM
Points: 84, Visits: 31
Actually, I'm right - this query will return 0 rows for both SELECT statements as it will never run - you cannot insert into a table with and Identity PK without specifying the column names on the INSERT query.

The script should have read:

INSERT INTO @student (StudentName, StudentResult)
VALUES( 'Hardy', 100), ('Rocky', 98), ('Panky', 99)





Post #1041939
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse